respect-validation/docs/rules/Yes.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

1.1 KiB

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

Categorization

  • Booleans

Changelog

Version Description
0.7.0 Created

See also: