BetweenValuesValidator class
A validator that checks if the value is between minValue and maxValue.
The BetweenValuesValidator can be used with FieldControllers holding
values of types int or double. It ensures that the
value is between minValue and maxValue.
If the value is null it is treated as valid by default.
Properties
- minValue: The minimum allowed for the value.
- maxValue: The maximum allowed for the value.
- message: An optional custom error message to display when invalid.
Example
FieldController<int> field = FieldController(
key: 'number',
validators:[BetweenValuesValidator(minValue:4, maxValue:6)],
);
// If field.value = 3, validation fails.
// If field.value = 7, validation fails.
// If field.value = 5, validation passes.
See also
- FormyValidator, the base class for custom validators.
- ValidationResult, which describes the outcome of validation.
- FieldController, which holds the field value to be validated.
- Inheritance
-
- Object
- FormyValidator<
num> - BetweenValuesValidator
Constructors
- BetweenValuesValidator({String? message, required num minValue, required num maxValue})
Properties
Methods
-
call(
FieldController< num> controller) → ValidationResult -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onValidate(
FieldController< num> controller) → ValidationResult -
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited