AnyOf

February 5, 2026 ยท View on GitHub

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

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

v::anyOf(v::intVal(), v::floatVal())->assert(15.5);
// Validation passes successfully

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

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

Template placeholders

PlaceholderDescription
subjectThe validated input or the custom validator name (if specified).

Categorization

  • Composite
  • Nesting

Changelog

VersionDescription
3.0.0Require at least two validators to be defined
2.0.0Created

See Also