Validator<T> class
abstract
Extensibility
Abstract base class for all validators.
A validator checks a single constraint on a value of type T and returns
interpolation parameters on failure, or null on success.
class MinValidator extends Validator<int> {
final int min;
const MinValidator({required this.min});
@override
String get code => 'number.too_small';
@override
Map<String, dynamic>? validate(int value) =>
value >= min ? null : {'min': min};
}
See also:
- AsyncValidator, for a rule that has to await something.
- VType, which accepts a validator through its add method.
Properties
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(
T value) → Map< String, dynamic> ? -
Validates
valueand returns interpolation parameters on failure, ornullon success.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited