operator | method

  1. @override
Validator<T> operator |(
  1. Validator<T> other
)
override

Combines this validator with another using OR logic.

At least one validator must pass for the combined validator to be valid. Only if both validators fail will the combined validator fail.

Parameters:

  • other (Validator<T>): The validator to combine with this one using OR logic

Returns a new OrValidator that requires at least one validator to pass.

Example:

final validator = emailValidator | phoneValidator;

Implementation

@override
Validator<T> operator |(Validator<T> other) {
  return OrValidator([...validators, other]);
}