operator | method
Combines two validators with a logical OR, same as using any
This is Sugar, it allows for more concise validator composition.
Implementation
IValidator operator |(IValidator other) {
if (this is AnyValidator && other is AnyValidator) {
final mv1 = this as AnyValidator;
return mv1.copyWith(validators: {...mv1.validators, ...other.validators});
}
if (this is AnyValidator) {
final mv = this as AnyValidator;
return mv.copyWith(validators: {...mv.validators, other});
}
if (other is AnyValidator) {
return other.copyWith(validators: {...other.validators, this});
}
return any([this, other]);
}