respect-validation/docs/rules/Yes.md
Henrique Moody 48405271c5
Replace placeholder "name" with "subject"
The `{{name}}` placeholder could represent different things depending on
the state of the Result, and referring to it as `{{name}}` seems
arbitrary. This commit changes it to `{{subject}}`, which is much more
generic and it describes well what that placeholder can mean.
2025-12-26 21:30:01 +01:00

1.6 KiB

Yes

  • Yes()
  • Yes(bool $locale)

Validates if the input considered as "Yes".

v::yes()->isValid('Y'); // true
v::yes()->isValid('Yea'); // true
v::yes()->isValid('Yeah'); // true
v::yes()->isValid('Yep'); // true
v::yes()->isValid('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)->isValid('Sim'); // true

Be careful when using $locale as TRUE because the it's very permissive:

v::yes(true)->isValid('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)->isValid('Yes'); // true

Templates

Yes::TEMPLATE_STANDARD

Mode Template
default {{subject}} must be similar to "Yes"
inverted {{subject}} must not be similar to "Yes"

Template placeholders

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

Categorization

  • Booleans

Changelog

Version Description
0.7.0 Created

See also: