any function

IEskValidator any(
  1. List<IEskValidator> validators
)

/////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// Passes the test if any of the EskValidators are valid, and fails if any are invalid

Implementation

// Combinators
//////////////////////////////////////////////////////////////////////////////////

/// Passes the test if any of the [EskValidator]s are valid, and fails if any are invalid
IEskValidator any(List<IEskValidator> validators) => EskValidator((value) {
      final results = <EskResult>[];

      for (final validator in validators) {
        final result = validator.validate(value);
        results.add(result);
        if (result.isValid) return result;
      }

      return EskResult(
        isValid: false,
        error: results.map((r) => r.error).join(' or '),
        value: value,
      );
    });