Validators class

Provides a set of built-in validators that can be used by form controls, form groups, and form arrays.

Constructors

Validators()

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 Properties

creditCard → Validator
Creates a validator that validates if the control's value is a valid credit card number.
no setter
email → Validator
Creates a validator that requires the control's value pass an email validation test.
no setter
required → Validator
Creates a validator that requires the control have a non-empty value.
no setter
requiredTrue → Validator
Creates a validator that requires the control's value be true. This validator is commonly used for required checkboxes.
no setter

Static Methods

any<T>(AnyValidatorFunctionTest<T> test) → Validator
Creates a validator that requires any element of the control's iterable value satisfies test.
compare(String controlName, String compareControlName, CompareOption compareOption, {bool allowNull = false}) → Validator
Creates a FormGroup validator that compares two controls in the group.
compose(List<Validator> validators) → Validator
Compose multiple validators into a single validator that returns the union of the individual error maps for the provided control of multiple validators.
composeOR(List<Validator> validators) → Validator
Compose multiple validators into a single validator that returns the union of the individual error maps for the provided control of multiple validators.
contains<T>(List<T> values) → Validator
Creates a validator that requires the control's value contains all the values specified in values.
debounced(AsyncValidator validator, int debounceTime) → AsyncValidator
Creates an asynchronous validator that delays the execution of another asynchronous validator by the specified debounceTime in milliseconds.
delegate(ValidatorFunction validator) → Validator
Creates a validator that delegates the validation to the external validator function.
delegateAsync(AsyncValidatorFunction validator, {int debounceTime = 0}) → AsyncValidator
Creates a validator that delegates the validation to the external asynchronous validator function.
equals<T>(T value) → Validator
Creates a validator that requires the control's value to be equals to argument value.
max<T>(T max) → Validator
Creates a validator that requires the control's value to be less than or equal to max value.
maxLength(int maxLength) → Validator
Creates a validator that requires the length of the control's value to be less than or equal to the provided maxLength.
min<T>(T min) → Validator
Creates a validator that requires the control's value to be greater than or equal to min value.
minLength(int minLength) → Validator
Creates a validator that requires the length of the control's value to be greater than or equal to the provided minLength.
mustMatch(String controlName, String matchingControlName, {bool markAsDirty = true}) → Validator
Creates a FormGroup validator that checks the controls controlName and matchingControlName have the same values.
number({bool allowNull = false, int allowedDecimals = 0, bool allowNegatives = true}) → Validator
Creates a validator that checks if a control's value is a valid number.
oneOf(List collection, {bool caseSensitive = true}) → Validator
Creates a validator that checks if the control's value is one of the values in the provided collection.
pattern(Pattern pattern, {String validationMessage = ValidationMessage.pattern}) → Validator
Creates a validator that requires the control's value to match a regex pattern.