respect-validation/docs/rules/OneOf.md
Henrique Moody 10df3211f5
Add "Categorization" section to rule documentations
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-11 19:16:21 +02:00

712 B

OneOf

  • OneOf(Validatable ...$rule)

Will validate if exactly one inner validator passes.

v::oneOf(v::digit(), v::alpha())->validate('AB'); // true
v::oneOf(v::digit(), v::alpha())->validate('12'); // true
v::oneOf(v::digit(), v::alpha())->validate('AB12'); // false
v::oneOf(v::digit(), v::alpha())->validate('*'); // false

The chains above validate if the input is either a digit or an alphabetic character, one or the other, but not neither nor both.

Categorization

  • Composite
  • Nesting

Changelog

Version Description
2.0.0 Created (see AnyOf)

See also: