mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 15:25:45 +01:00
652 B
652 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.
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Created (see AnyOf) |
See also: