DivisibleByValidator class
A validator that checks if the value is divisible by denominator.
The DivisibleByValidator can be used with FieldControllers holding
values of type int. It ensures that the
value is divisible by denominator.
If the value is null it is treated as valid by default.
Properties
- denominator: The denominator of the division.
- message: An optional custom error message to display when invalid.
Example
FieldController<int> field = FieldController(
key: 'number',
validators:[DivisibleByValidator(4)],
);
// If field.value = 3, validation fails.
// If field.value = 4, validation passes.
// If field.value = 8, 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<
int> - DivisibleByValidator
Constructors
- DivisibleByValidator(int denominator, {String? message})
Properties
- denominator → int
-
The denominator of the division.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- message → String?
-
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
FieldController< int> controller) → ValidationResult -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onValidate(
FieldController< int> controller) → ValidationResult -
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited