mirror of
https://github.com/Respect/Validation.git
synced 2026-03-18 08:09:51 +01:00
Since we now have PHP ISO Codes as a dependency[1], it doesn't make
sense to keep dealing with this data ourselves.
[1]: 04b2722d02
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
42 lines
999 B
Markdown
42 lines
999 B
Markdown
# LanguageCode
|
|
|
|
- `LanguageCode()`
|
|
- `LanguageCode("alpha-2"|"alpha-3" $set)`
|
|
|
|
Validates whether the input is language code based on [ISO 639][].
|
|
|
|
**This rule requires [sokil/php-isocodes][] and [sokil/php-isocodes-db-only][] to be installed.**
|
|
|
|
```php
|
|
v::languageCode()->validate('pt'); // true
|
|
v::languageCode()->validate('en'); // true
|
|
v::languageCode()->validate('it'); // true
|
|
v::languageCode('alpha-3')->validate('ita'); // true
|
|
v::languageCode('alpha-3')->validate('eng'); // true
|
|
```
|
|
|
|
This rule supports the two[ISO 639][] sets:
|
|
|
|
- `alpha-2`
|
|
- `alpha-3`
|
|
|
|
## Categorization
|
|
|
|
- ISO codes
|
|
- Localization
|
|
|
|
## Changelog
|
|
|
|
Version | Description
|
|
--------|-------------
|
|
3.0.0 | Require [sokil/php-isocodes][] and [sokil/php-isocodes-db-only][]
|
|
1.1.0 | Created
|
|
|
|
***
|
|
See also:
|
|
|
|
- [CountryCode](CountryCode.md)
|
|
|
|
[ISO 639]: https://en.wikipedia.org/wiki/ISO_639-3
|
|
[sokil/php-isocodes]: https://github.com/sokil/php-isocodes
|
|
[sokil/php-isocodes-db-only]: https://github.com/sokil/php-isocodes-db-only
|