respect-validation/docs/CountryCode.md
William Espindola a79e702173
Apply contribution guidelines to "CountryCode" rule
The "AbstractSearcher" already does most of the job that "CountryCode"
was doing, so using it as parent class made more sense. That also makes
the validation case-sensitive which is not a problem since the standard
ISO 3166-1 in fact enforces an specific case for the country codes.

The documentation about the rule is also updated.

Co-Authored-By: Henrique Moody <henriquemoody@gmail.com>
2018-06-15 18:49:52 +02:00

854 B

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' 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).

Changelog

Version Description
2.0.0 Became case-sensitive
0.5.0 Created

See also: