2015-01-30 09:40:06 +01:00
|
|
|
# CountryCode
|
|
|
|
|
2017-03-27 14:47:07 +02:00
|
|
|
- `CountryCode()`
|
2018-06-13 05:01:03 +02:00
|
|
|
- `CountryCode(string $set)`
|
2015-01-30 09:40:06 +01:00
|
|
|
|
2018-06-13 05:01:03 +02:00
|
|
|
Validates whether the input is a country code in [ISO 3166-1][] standard.
|
2015-01-30 09:40:06 +01:00
|
|
|
|
|
|
|
```php
|
2015-10-20 02:53:25 +02:00
|
|
|
v::countryCode()->validate('BR'); // true
|
2018-06-13 05:01:03 +02:00
|
|
|
|
|
|
|
v::countryCode('alpha-2')->validate('NL'); // true
|
|
|
|
v::countryCode('alpha-3')->validate('USA'); // true
|
|
|
|
v::countryCode('numeric')->validate('504'); // true
|
2015-01-30 09:40:06 +01:00
|
|
|
```
|
|
|
|
|
2018-06-13 05:01:03 +02:00
|
|
|
This rule supports the three sets of country codes:
|
|
|
|
|
|
|
|
- ISO 3166-1 alpha-2 (`'alpha-2'` or `CountryCode::ALPHA2`)
|
|
|
|
- ISO 3166-1 alpha-3 (`'alpha-3'` or `CountryCode::ALPHA3`)
|
|
|
|
- ISO 3166-1 numeric (`'numeric'` or `CountryCode::NUMERIC`).
|
|
|
|
|
|
|
|
When no set is defined the rule uses `'alpha-2'` (`CountryCode::ALPHA2`).
|
|
|
|
|
2021-03-19 14:59:26 +01:00
|
|
|
This rules uses data from [iso-codes][].
|
2019-05-26 14:41:29 +02:00
|
|
|
|
2019-05-11 18:32:13 +02:00
|
|
|
## Categorization
|
|
|
|
|
|
|
|
- ISO codes
|
|
|
|
- Localization
|
|
|
|
|
2017-03-27 22:04:13 +02:00
|
|
|
## Changelog
|
|
|
|
|
|
|
|
Version | Description
|
|
|
|
--------|-------------
|
2018-06-13 05:01:03 +02:00
|
|
|
2.0.0 | Became case-sensitive
|
2017-03-27 22:04:13 +02:00
|
|
|
0.5.0 | Created
|
|
|
|
|
2015-08-20 06:38:41 +02:00
|
|
|
***
|
2015-01-30 09:40:06 +01:00
|
|
|
See also:
|
|
|
|
|
2018-12-11 13:31:50 +01:00
|
|
|
- [CurrencyCode](CurrencyCode.md)
|
|
|
|
- [LanguageCode](LanguageCode.md)
|
|
|
|
- [PostalCode](PostalCode.md)
|
|
|
|
- [SubdivisionCode](SubdivisionCode.md)
|
2017-03-28 11:53:14 +02:00
|
|
|
- [Tld](Tld.md)
|
2018-06-13 05:01:03 +02:00
|
|
|
|
|
|
|
[ISO 3166-1]: https://wikipedia.org/wiki/ISO_3166-1
|
2021-03-19 14:59:26 +01:00
|
|
|
[iso-codes]: https://salsa.debian.org/iso-codes-team/iso-codes
|