respect-validation/docs/rules/Yes.md

58 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

2015-01-30 09:40:06 +01:00
# Yes
- `Yes()`
- `Yes(bool $locale)`
2015-01-30 09:40:06 +01:00
Validates if the input considered as "Yes".
2015-01-30 09:40:06 +01:00
```php
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
2015-01-30 09:40:06 +01:00
```
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:
```php
setlocale(LC_ALL, 'pt_BR');
v::yes(true)->validate('Sim'); // true
```
Be careful when using `$locale` as `TRUE` because the it's very permissive:
```php
v::yes(true)->validate('Yydoesnotmatter'); // true
```
Besides that, with `$locale` as `TRUE` it will consider any character starting
with "Y" as valid:
```php
setlocale(LC_ALL, 'ru_RU');
v::yes(true)->validate('Yes'); // true
```
2015-01-30 09:40:06 +01:00
## Categorization
- Booleans
## Changelog
Version | Description
--------|-------------
0.7.0 | Created
***
2015-01-30 09:40:06 +01:00
See also:
2018-12-11 13:31:50 +01:00
- [BoolType](BoolType.md)
- [BoolVal](BoolVal.md)
- [No](No.md)
[nl_langinfo]: http://php.net/nl_langinfo