respect-validation/docs/validators/All.md
Henrique Moody d2198dfd01
Replace isValid() calls with assert()
There's more value on showing how `assert()` displays the validation
messages than simply showing if `isValid()` returns `true` or `false`.

However, that increases the chances of having outdated documentation, so
I created a doc linter that updates the Markdown files with the
correct message.
2026-01-13 23:37:06 -07:00

1.2 KiB

All

  • All(Validator $validator)

Validates all items of the input against a given validator.

v::all(v::intType())->assert([1, 2, 3]);
// Validation passes successfully

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

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

Template as prefix

The template serves as a prefix to the template of the inner validator.

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

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

Categorization

  • Comparisons
  • Transformations

Changelog

Version Description
3.0.0 Created

See also: