MyFormFieldValidator class

A class that holds a list of MyFormFieldValidationRules and generates a FormFieldValidator<String> function to be used with TextFormField.

This class provides a chainable API to easily build validation rules for a field.

Annotations

Constructors

MyFormFieldValidator.new()
Creates an empty FieldValidator to start building a chain of rules.
const
MyFormFieldValidator.fromRules(List<MyFormFieldValidationRule> rules)
Creates a FieldValidator from an existing list of rules.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
rules List<MyFormFieldValidationRule>
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(MyFormFieldValidationRule rule) MyFormFieldValidator
Adds a custom MyFormFieldValidationRule to the validator chain.
confirmsPassword(ValueGetter<String?> passwordValueGetter, {String? message}) MyFormFieldValidator
Adds a ConfirmPasswordRule to the validator chain. Requires a getter for the value of the password field to compare against.
email({String? message}) MyFormFieldValidator
Adds an EmailRule to the validator chain.
getValidator({BuildContext? context}) FormFieldValidator<String>
Generates the validator function compatible with TextFormField. It iterates through the provided rules and returns the first error found.
isNumeric({String? message}) MyFormFieldValidator
Adds a NumericRule to the validator chain.
matchesRegex(RegExp regex, {required String message}) MyFormFieldValidator
Adds a RegexRule to the validator chain.
maxLength(int maxLength, {String? message}) MyFormFieldValidator
Adds a MaxLengthRule to the validator chain.
minLength(int minLength, {String? message}) MyFormFieldValidator
Adds a MinLengthRule to the validator chain.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
numberRange({required num min, required num max, String? message}) MyFormFieldValidator
Adds a NumberRangeRule to the validator chain.
passwordComplexity({String? message}) MyFormFieldValidator
Adds a PasswordComplexityRule to the validator chain.
required({String? message}) MyFormFieldValidator
Adds a RequiredRule to the validator chain.
toString() String
A string representation of this object.
inherited

Operators

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