Validators class
A collection of common validation rules for form fields.
Constructors
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
-
custom(
ValidationFunction func, {required String message}) → ValidationRule -
Creates a custom validation rule using the given
func. -
email(
{String message = 'Invalid email format'}) → ValidationRule - Validation rule to check for valid email format.
-
maxLength(
int length, {String? message}) → ValidationRule - Validation rule to check the maximum length of a string.
-
minLength(
int length, {String? message}) → ValidationRule - Validation rule to check the minimum length of a string.
-
oneLowerCase(
{String message = 'Must contain at least one lowercase letter'}) → ValidationRule - Validation rule to require at least one lowercase letter.
-
oneNumber(
{String message = 'Must contain at least one number'}) → ValidationRule - Validation rule to require at least one numeric digit.
-
oneSpecial(
{String message = 'Must contain at least one special character'}) → ValidationRule - Validation rule to require at least one special character.
-
oneUpperCase(
{String message = 'Must contain at least one uppercase letter'}) → ValidationRule - Validation rule to require at least one uppercase letter.
-
pattern(
String pattern, {required String message}) → ValidationRule -
Validation rule to check if a string matches a regex
pattern. -
required(
{String message = 'This field is required'}) → ValidationRule - Validation rule to require a non-empty string.
-
validate(
String? value, List< ValidationRule> rules) → String? -
Validates the
valueagainst a list ofrules.