सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
Formdator एक Dart पैकेज है जो सजावट पैटर्न के उपयोग से एकत्रित किए जा सकने वाले लचीले फॉर्म फ़ील्ड वैधता चेकर का संग्रह प्रदान करता है। यह विकासकर्ताओं को बहुत सारे वैधता नियमों को आसानी से जोड़ने में सक्षम बनाता है, जिससे फॉर्म में पुनर्उपयोगी और मॉड्यूलर वैधता तर्क संभव होता है। डायनामिक या जटिल इनपुट वैधता की आवश्यकता वाले एप्लिकेशन के लिए उपयुक्त है, यह विभिन्न प्लेटफॉर्म जैसे मोबाइल, वेब और डेस्कटॉप को समर्थन देता है। पैकेज साफ और एकीकृत कोड पर जोर देता है और Flutter के फॉर्म इकोसिस्टम के साथ आसानी से एकीकृत होता है।
उपयोग
डायनामिक फॉर्म सत्यापन
जटिल इनपुट नियम
पुनर्उपयोगी सत्यापन घटक
क्रॉस-प्लेटफॉर्म फॉर्म्स
कस्टम वैधता चेन
रियल-टाइम प्रतिक्रिया
मुख्य विशेषताएँ
योजनाबद्ध वैधता कर्ता
डिकोरेटर पैटर्न कार्यान्वयन
Platform-agnostic
Flutter फॉर्म के साथ आसान एकीकरण
मॉड्यूलर डिज़ाइन
विस्तारयोग्य नियम वैधता तर्क
इनके लिए उपयुक्त
जटिल फॉर्म बना रहे विकासकर्ता
रखरखाव योग्य सत्यापन कोड की आवश्यकता वाली टीमें
बहु-नियम प्रामाणीकरण की आवश्यकता वाले ऐप्स
क्रॉस-प्लेटफ़ॉर्म आवश्यकताओं वाले Flutter प्रोजेक्ट
कोड पुनर्उपयोग पर बल देने वाले प्रोजेक्ट
विचार योग्य बातें
डिकोरेटर पैटर्न की समझ आवश्यक है
सरल फॉर्म के लिए जटिलता बढ़ सकती है
मूल उदाहरणों के अलावा सीमित दस्तावेज़न
फॉर्म विजेट्स में सही सेटअप पर निर्भर करता है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Formdator is a fully object-oriented package for validating Flutter form fields.
Its main benefits, compared to all other similar packages, include:
Dependency-free: there is only pure Dart code.
Object-oriented mindset: the elements for validation are immutable
objects that can be combined in various configurations.
Classes with short — yet meaningful — names like Req for required fields;
ReqEmail for non-empty, well-formed emails; Len for length constraints;
Int for integer-only values; and so on.
Easy-to-compose validators: e.g., the command Trim(Email()) produces a
validator that trims an email value before validating it.
Multiple validation at once: you can apply multiple validation rules at once
by using the Pair or Rules classes.
Built-in set of compound validators: e.g., to validate an email and limit its
length to a maximum of 50 characters, simply use an instance of
Email.len(50) — write less; do more!
For easier integration with Flutter form fields, every validator implements the
call() method. As a result, any validator object can be called as a function —
Callable Classes.
Getting Started
The following code snippet demonstrates how you can easily group the Rules,
Req, Len and Email classes together to create a kind of
'email-max-50-characters' constraint.
@overrideWidgetbuild(BuildContext context) {
returnTextFormField(
validator: Rules<String>([ // The "Rules" class performs multiple validations at once.Req(blank: 'Please enter the email'), // "blank" is the error message in case of field left blank.Len.max(50, long: 'Email length cannot exceed 50 characters'), // "long" is the error message if an input value is too long.Email(mal: 'Malformed email'), // "mal" is the error message in case of malformed email.
]),
);
}
Or — even better — use the compound validator ReqEmail to perform the same
task.
logic
— validation logic and unit testing (Equal, Ok, Nok, ValueBack).
net —
internet (Email, Ipv4, Ipv6, MacAddr, Url, etc.).
numeric
— validators related to numbers or digits (Digit, Hex, Int, Num, etc.).
Demo application
The demo application provides a fully working example, focused on demonstrating
exactly four validators in action — Pair, ReqLen, ReqEmail, and Equal.
You can take the code in this demo and experiment with it.
To run the demo application:
git clone https://github.com/dartoos-dev/formdator.git
cd formdator/example/
flutter run -d chrome
This should launch the demo application on Chrome in debug mode.
Contribute
Contributors are welcome!
Open an issue regarding an improvement, a bug you noticed, or ask to be
assigned to an existing one.
If the issue is confirmed, fork the repository, do the changes on a separate
branch and make a Pull Request.
After review and acceptance, the Pull Request is merged and closed.
Make sure the command below passes before making a Pull Request.