Validates that a value is a valid country code.
Country(
string $code = 'alpha-2',
?string $message = null
);// default alpha-2 code
Validator::country()->validate('pt'); // true
// alpha-3 code
Validator::country(code: 'alpha-3')->validate('prt'); // trueNote
An UnexpectedValueException will be thrown when the code value is not a valid option.
Note
An UnexpectedValueException will be thrown when the input value is not a string.
type: string default: alpha-2
Set code type to validate the country. Check the official country codes list for more information.
Available options:
alpha-2: two-letter codealpha-3: three-letter code
type: ?string default: The {{ name }} value is not a valid country.
Message that will be shown if the input value is not a valid country code.
The following parameters are available:
| Parameter | Description |
|---|---|
{{ value }} |
The current invalid value |
{{ name }} |
Name of the invalid value |
{{ code }} |
Selected code type |
0.2.0Created