or function

Validator or(
  1. Validator validator1,
  2. Validator validator2
)

Passes the test if either of the Validators are valid, and fails if both are invalid

Implementation

Validator or(Validator validator1, Validator validator2) {
  return (value) {
    final res1 = validator1(value);
    final res2 = validator2(value);

    return Result(
      isValid: res1.isValid || res2.isValid,
      expected: '${res1.expected} or ${res2.expected}',
      value: value,
    );
  };
}