all<TIn, TOut> static method

ValidateFunc<TIn, TOut> all<TIn, TOut>(
  1. List<LoValidator<TIn, TOut>> validators, [
  2. TOut? defaultError
])

Checks whether all validators have no error (Like AND). Returns first error (or defaultError if not null) otherwise.

Implementation

static ValidateFunc<TIn, TOut> all<TIn, TOut>(
  List<LoValidator<TIn, TOut>> validators, [
  TOut? defaultError,
]) {
  return (input) {
    for (final validator in validators) {
      final error = validator.validate(input);
      if (error != null) {
        return defaultError ?? error;
      }
    }

    return null;
  };
}