Validator class abstract
An interface to be implemented as classes acting as validators.
Usage
@Directive(
selector: '[custom-validator]',
providers: const [
const ExistingProvider.forToken(
NG_VALIDATORS,
CustomValidatorDirective,
),
]
)
class CustomValidatorDirective implements Validator {
@override
Map<String, dynamic> validate(AbstractControl control) {
// The length of the input string can't be longer than 14 characters.
final value = c.value;
if (value is String && value.length > 14) {
return {
'length': value.length,
};
}
return null;
}
}
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
-
validate(
AbstractControl control) → Map< String, dynamic> ? - Returns a map of the errors associated with this control.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited