UValidators class abstract

Ready-made form validators; each returns a FormFieldValidator for validator:. UTextField(validator: UValidators.email())

Constructors

UValidators()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

alphanumeric({String? requiredMessage, String? invalidMessage, bool isRequired = true}) → FormFieldValidator<String>
Only English letters and digits. UValidators.alphanumeric()
cardNumber({String? requiredMessage, String? invalidMessage, bool isRequired = true}) → FormFieldValidator<String>
Checks an Iranian card number (Luhn). UValidators.cardNumber()
combineValidators<T>(List<FormFieldValidator<T>> validators) → FormFieldValidator<T>
Runs validators in order and shows the first error. UValidators.combineValidators([UValidators.required(), UValidators.email()])
complexPassword() → FormFieldValidator<String>
Required + 8 chars + strong password, with English messages. UValidators.complexPassword()
email({String? requiredMessage, String? invalidMessage, bool isRequired = true}) → FormFieldValidator<String>
Checks an email address. UValidators.email()
exactLength({required int length, required String message}) → FormFieldValidator<String>
Fails unless exactly length characters. UValidators.exactLength(length: 10, message: "Must be 10 digits")
iban({String? requiredMessage, String? invalidMessage, bool isRequired = true}) → FormFieldValidator<String>
Checks an IBAN / Sheba number ("IR" + 24 digits). UValidators.iban()
iranianNationalCode({String? requiredMessage, String? invalidMessage, bool isRequired = true}) → FormFieldValidator<String>
Checks an Iranian national code (کد ملی) checksum. UValidators.iranianNationalCode()
iranianTaxPayerCode({String? requiredMessage, String? invalidMessage, bool isRequired = true}) → FormFieldValidator<String>
Checks an Iranian tax memory id (شناسه یکتای حافظه مالیاتی). UValidators.iranianTaxPayerCode()
match({required String otherValue, required String mismatchMessage}) → FormFieldValidator<String>
Must equal otherValue, e.g. "repeat password". UValidators.match(otherValue: passwordController.text, mismatchMessage: "Not the same")
matchController({required TextEditingController controller, required String mismatchMessage}) → FormFieldValidator<String>
Must equal the current text of controller (reads it on every check). UValidators.matchController(controller: passwordController, mismatchMessage: "Not the same")
maxLength({required int maxLength, required String message}) → FormFieldValidator<String>
Fails when longer than maxLength. UValidators.maxLength(maxLength: 20, message: "Too long")
minLength({required int minLength, required String message}) → FormFieldValidator<String>
Fails when shorter than minLength. UValidators.minLength(minLength: 8, message: "Too short")
number({String? requiredMessage, String? invalidMessage, int? minLength, int? maxLength, bool isRequired = true}) → FormFieldValidator<String>
Only digits (Persian/Arabic digits accepted), optional length limits. UValidators.number(minLength: 4)
numberRange({required double min, required double max, required String rangeMessage, required String invalidNumberMessage, bool isRequired = true}) → FormFieldValidator<String>
Number between min and max (inclusive). UValidators.numberRange(min: 1, max: 100, rangeMessage: "1-100", invalidNumberMessage: "Not a number")
password({required String weakMessage, String? requiredMessage, bool isRequired = true}) → FormFieldValidator<String>
Needs 8+ chars with upper, lower, digit and symbol. UValidators.password(weakMessage: "Too weak")
pattern({required RegExp pattern, required String message, bool isRequired = true}) → FormFieldValidator<String>
Must match your own regular expression. UValidators.pattern(pattern: RegExp(r"^09\d{9}$"), message: "Invalid")
phone({String? requiredMessage, String? invalidMessage, bool isRequired = true}) → FormFieldValidator<String>
Checks a phone number (8-15 digits, optional +). UValidators.phone()
required<T>({String? message}) → FormFieldValidator<T>
Fails on null, "", empty list or empty map. UValidators.required()
url({String? requiredMessage, String? invalidMessage, bool isRequired = true}) → FormFieldValidator<String>
Checks a web address (http/https optional). UValidators.url()
validateForm({required GlobalKey<FormState> key, required VoidCallback action}) → void
Runs action only when every field in the form is valid. UValidators.validateForm(key: formKey, action: save)