respect-validation/docs/validators/AnyOf.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.4 KiB

AnyOf

  • AnyOf(Validator $validator1, Validator $validator2, Validator ...$validator)

This is a group validator that acts as an OR operator.

v::anyOf(v::intVal(), v::floatVal())->isValid(15.5); // true

In the sample above, IntVal() doesn't validates, but FloatVal() validates, so AnyOf() returns true.

AnyOf() returns true if at least one inner validator passes.

Templates

AnyOf::TEMPLATE_STANDARD

Mode Template
default {{subject}} must pass at least one of the rules
inverted {{subject}} must pass at least one of the rules

Template placeholders

Placeholder Description
subject The validated input or the custom validator name (if specified).

Categorization

  • Composite
  • Nesting

Changelog

Version Description
3.0.0 Require at least two validators to be defined
2.0.0 Created

See also: