OrValidator<T> class

A validator that combines multiple validators with OR logic.

OrValidator passes if at least one of the wrapped validators passes. Only fails if all validators fail. Useful for accepting multiple valid formats.

Example:

OrValidator([
  EmailValidator(),
  PhoneValidator(),
])
Inheritance

Constructors

OrValidator(List<Validator<T>> validators)
Creates an OrValidator from a list of validators.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
validators List<Validator<T>>
The list of validators to combine with OR logic.
final

Methods

combine(Validator<T> other) Validator<T>
Combines this validator with another validator using AND logic.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldRevalidate(FormKey source) bool
Determines if this validator should be re-run when the specified form key changes.
override
toString() String
A string representation of this object.
inherited
validate(BuildContext context, T? value, FormValidationMode state) FutureOr<ValidationResult?>
Validates the given value and returns a validation result.
override

Operators

operator &(Validator<T> other) Validator<T>
Combines this validator with another using AND logic (alias for combine).
inherited
operator +(Validator<T> other) Validator<T>
Combines this validator with another using AND logic (alias for combine).
inherited
operator ==(Object other) bool
The equality operator.
override
operator unary-() Validator<T>
Negates this validator's result (alias for ~ operator).
inherited
operator |(Validator<T> other) Validator<T>
Combines this validator with another using OR logic.
override
operator ~() Validator<T>
Negates this validator's result.
inherited