respect-validation/docs/rules/AnyOf.md
Henrique Moody a0d6355980
Update some templates and improve tests
Some templates were a bit confusing, and I would like to favour adding
the `{{name}}` at the beginning of the templates as it helps when
reading nested messages.

I also deleted the regression tests for issue #1348, because it's a
non-issue, actually. The best approach to that problem is indeed using
`When` insteaf of `OneOf`.
2024-12-27 15:55:55 +01:00

1.3 KiB

AnyOf

  • AnyOf(Rule $rule1, Rule $rule2, Rule ...$rule)

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 {{name}} must pass at least one of the rules
inverted {{name}} must pass at least one of the rules

Template placeholders

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

Categorization

  • Composite
  • Nesting

Changelog

Version Description
3.0.0 Require at least two rules to be passed
2.0.0 Created

See also: