MustMatchValidator<T> class
A validator that checks if the value is equal to the value of otherField.
The MustMatchValidator can be used with FieldControllers holding
values of type T. It ensures that the value is equal to the value
of otherField.
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: 'string',
fields: [
FieldConfig<string>(key: 'string1'),
FieldConfig<string>(key: 'string2', validators: [MustMatchValidator(otherField: 'string1')]),
],
);
// If 'string1' value = 'abc' and 'string2' value = '123', validation fails.
// If 'string1' value = 'abc' and 'string2' value = 'abc, 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> - MustMatchValidator
Constructors
- MustMatchValidator({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