all function

AllValidator all(
  1. List<IValidator> validators, {
  2. String? message,
  3. bool collecting = false,
})

Passes the test if all of the Validators are valid, and fails if any of them are invalid

By default, validation stops at the first failure and chains transformed values. If collecting is true, all validators are run against the original input value and all failures are collected without value chaining.

Usage Examples:

// Standard behavior: stop at first failure, chain values
final passwordValidator = all([
  toString(),                         // Convert to string first
  stringLength([isGte(8)]),          // Then validate length (chained value)
  stringMatchesPattern(r'[A-Z]'),     // Must contain uppercase
]);

// Collecting behavior: show all errors at once
final formValidator = all([
  isType<String>(),                   // Must be a string
  stringLength([isGte(3)]),          // Must be at least 3 chars
  stringMatchesPattern(r'[A-Z]'),     // Must contain uppercase
  stringMatchesPattern(r'[0-9]'),     // Must contain number
], collecting: true);

// Will show ALL validation errors, not just the first one
final result = formValidator.validate(123);
// result.expectations will contain errors for type, length, uppercase, and number

Implementation

AllValidator all(List<IValidator> validators, {String? message, bool collecting = false}) {
  return AllValidator(validators, message: message, collecting: collecting);
}