all function

Validator all(
  1. List<Validator> validators
)

Valid if every validator is valid or returns the first invalid result

Implementation

Validator all(List<Validator> validators) {
  return (value) {
    if (validators.isNotEmpty) {
      for (final validator in validators) {
        final result = validator.call(value);
        if (result.isNotValid) return result;
      }
    }

    return Result.valid;
  };
}