respect-validation/docs/validators/All.md
Henrique Moody 81310cc4d9
Rename namespace Rules to Validators
Since that namespace contains our “validators”, naming it as such makes
much more sense.
2026-01-05 17:36:35 +01:00

1.1 KiB

All

  • All(Validator $validator)

Validates all items of the input against a given validator.

v::all(v::intType())->isValid([1, 2, 3]); // true
v::all(v::intType())->isValid([1, 2, '3']); // false

This validator is similar to Each, but as opposed to the former, it displays a single message when asserting an input.

Note

This validator uses Length with [GreaterThan][GreaterThan.md] internally. If an input has no items, the validation will fail.

Templates

All::TEMPLATE_STANDARD

Mode Template
default Every item in
inverted Every item in

This template serve as message prefixes.:

v::all(v::floatType())->assert([1.5, 2]);
// Message: Every item in `[1.5, 2]` must be float

v::not(v::all(v::intType()))->assert([1, 2, -3]);
// Message: Every item in `[1, 2, -3]` must not be an integer

Categorization

  • Comparisons
  • Transformations

Changelog

Version Description
3.0.0 Created

See also: