BiggerThanValidator<T> class
A validator that checks if the value is greater than or equal to the value of otherField.
The BiggerThanValidator can be used with FieldControllers holding
values of type num
, String
, List
, Map
, or Set
. It ensures that
the value is greater than or equal to the value of otherField.
For String
, List
, Map
, and Set
, the comparison is done based on length.
For num
, the comparison is done directly on the numeric value.
If the value is null
, it is treated as valid by default.
Properties
- message: An optional custom error message to display when invalid.
Example
GroupController group = GroupController(
key: 'num',
fields: [
FieldConfig<int>(key: 'num1'),
FieldConfig<int>(key: 'num2', validators: [BiggerThanValidator(otherField: 'num1')]),
],
);
// If 'num1' value = 10 and 'num2' value = 5, validation fails.
// If 'num1' value = 5 and 'num2' value = 10, validation passes.
See also
- FormyCrossValidator, the base class for cross-field validators.
- ValidationResult, which describes the outcome of validation.
- FieldController, which holds the field value to be validated.
- Inheritance
-
- Object
- FormyValidator<
T> - FormyCrossValidator<
T> - BiggerThanValidator
Constructors
- BiggerThanValidator.new({required String otherField, String? message})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- message → String?
-
finalinherited
- otherController → FieldController
-
no setterinherited
- otherField → String
-
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
FieldController< T> controller) → ValidationResult -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onValidate(
FieldController< T> controller) → ValidationResult -
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited