OrValidator class
A validator that checks if the value passes in at least one FormyValidator.
The OrValidator can be used with FieldControllers holding values of any types. It ensures that the value passes in at least one FormyValidator
Properties
- validators: List of FormyValidator that the value must pass in at least one.
- message: An optional custom error message to display when invalid.
Example
FieldController<String> field = FieldController(
key: 'name',
validators:[
PatternValidator(RegExp(r'[^[0-9]+$')),
EmailValidator(),
]
);
// If field.value = 'Maria', validation fails.
// If field.value = 'maria@email.com', validation passes.
// If field.value = '123456', 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.
- EmailValidator, which validates email.
- PatternValidator, which validates a pattern.
- Inheritance
-
- Object
- FormyValidator
- OrValidator
Constructors
-
OrValidator.new(List<
FormyValidator> validators, {required String? message})
Properties
- 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
-
validators
→ List<
FormyValidator> -
List of FormyValidator that the value must pass in at least one.
final
Methods
-
call(
FieldController controller) → ValidationResult -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onValidate(
FieldController controller) → ValidationResult -
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited