mirror of
https://github.com/Respect/Validation.git
synced 2026-03-18 08:09:51 +01:00
The "Yes" rule extends "Regex" rule. The only reasons why that is useful is because "Yes" uses regular expressions to validate the inputs. However, the "Yes" rule is way more complex simply validating a regular expressing and having "Regex" as its parent is also a little bit misleading. This commit will: * Remove unnecessary inheritance from "Yes" rule; * Improve the documentation of the "Yes" rule; * Enhance the unit tests of the "Yes" rule. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
1,011 B
1,011 B
Yes
Yes()Yes(bool $locale)
Validates if the input considered as "Yes".
v::yes()->validate('Y'); // true
v::yes()->validate('Yea'); // true
v::yes()->validate('Yeah'); // true
v::yes()->validate('Yep'); // true
v::yes()->validate('Yes'); // true
This rule is case insensitive.
If $locale is TRUE, it will use the value of nl_langinfo with YESEXPR
constant, meaning that it will validate the input using your current location:
setlocale(LC_ALL, 'pt_BR');
v::yes(true)->validate('Sim'); // true
Be careful when using $locale as TRUE because the it's very permissive:
v::yes(true)->validate('Yydoesnotmatter'); // true
Besides that, with $locale as TRUE it will consider any character starting
with "Y" as valid:
setlocale(LC_ALL, 'ru_RU');
v::yes(true)->validate('Yes'); // true
Changelog
| Version | Description |
|---|---|
| 0.7.0 | Created |
See also: