formdator
एक फॉर्म फ़ील्ड वैलिडेटर का संग्रह जो संयोजन के माध्यम से चुने जा सकते हैं और विभिन्न संयोजनों में समूहित किए जा सकते हैं — डेकोरेटर पैटर्न।
Flutter फॉर्म फ़ील्ड्स को सत्यापित करने के लिए ऑब्जेक्ट-ओरिएंटेड पैकेज।
यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।
Formdator — Formidable Validator.
Formdator is a fully object-oriented package for validating Flutter form fields. Its main benefits, compared to all other similar packages, include:
Req for required fields;
ReqEmail for non-empty, well-formed emails; Len for length constraints;
Int for integer-only values; and so on.Trim(Email()) produces a
validator that trims an email value before validating it.Pair or Rules classes.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.
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.
@override
Widget build(BuildContext context) {
return TextFormField(
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.
@override
Widget build(BuildContext context) {
return TextFormField(
validator: ReqEmail.len(
50,
blank: 'Please enter the email',
mal: 'Malformed email',
long: 'Email length cannot exceed 50 characters',
),
);
}
The shorter command ReqEmail.len(50) is equivalent to the much longer command
Rules<String>([Req(), Len.max(50), Email()]) — write less; do more!
For a complete list of validators with detailed information about each one (constructors, parameters, etc.):
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.
Contributors are welcome!
Make sure the command below passes before making a Pull Request.
dart analyze && sudo dart test
उपयोग के अनुसार छाँटें, गतिविधि की तुलना करें और अपनाने से पहले मूल प्रोजेक्ट की आवश्यकताएँ जाँचें।
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗