mirror of
https://github.com/Respect/Validation.git
synced 2024-05-27 02:42:23 +02:00
2060207f44
Since we already have that library as a dependency of our repository, it makes sense to use it as a source of country codes instead of keeping a list of currencies ourselves. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
1.1 KiB
1.1 KiB
CountryCode
CountryCode()
CountryCode(string $set)
Validates whether the input is a country code in ISO 3166-1 standard.
v::countryCode()->validate('BR'); // true
v::countryCode('alpha-2')->validate('NL'); // true
v::countryCode('alpha-3')->validate('USA'); // true
v::countryCode('numeric')->validate('504'); // true
This rule supports the three sets of country codes:
- ISO 3166-1 alpha-2 (
'alpha-2'
orCountryCode::ALPHA2
) - ISO 3166-1 alpha-3 (
'alpha-3'
orCountryCode::ALPHA3
) - ISO 3166-1 numeric (
'numeric'
orCountryCode::NUMERIC
).
When no set is defined the rule uses 'alpha-2'
(CountryCode::ALPHA2
).
This rule uses data from sokil/php-isocodes.
Categorization
- ISO codes
- Localization
Changelog
Version | Description |
---|---|
2.0.0 | Became case-sensitive |
0.5.0 | Created |
See also: