This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ # Country
2+
3+ Validates that a value is a valid country code.
4+
5+ ``` php
6+ Country(
7+ string $code = 'alpha-2',
8+ string $message = 'The "{{ name }}" value is not a valid country code, "{{ value }}" given.'
9+ );
10+ ```
11+
12+ ## Basic Usage
13+
14+ ``` php
15+ // Default alpha-2 code
16+ Validator::country()->validate('PT'); // true
17+ Validator::country(code: 'alpha-2')->validate('PT'); // true
18+
19+ // Alpha-3 code
20+ Validator::country(code: 'alpha-3')->validate('PRT'); // true
21+ ```
22+
23+ > ** Note**
24+ > An ` UnexpectedValueException ` will be thrown when the ` code ` value is not a valid option.
25+
26+ > ** Note**
27+ > An ` UnexpectedValueException ` will be thrown when the input value is not a ` string ` .
28+
29+ ## Options
30+
31+ ### ` code `
32+
33+ type: ` string ` default: ` alpha-2 `
34+
35+ Set code type to validate the country.
36+ Check the [ official country codes] ( https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes ) list for more information.
37+
38+ Available options:
39+
40+ - ` alpha-2 ` : two-letter code
41+ - ` alpha-3 ` : three-letter code
42+
43+ ### ` message `
44+
45+ type ` string ` default: ` The "{{ name }}" value is not a valid country code, "{{ value }}" given. `
46+
47+ Message that will be shown if the input value is not a valid country code.
48+
49+ The following parameters are available:
50+
51+ | Parameter | Description |
52+ | ---------------| ---------------------------|
53+ | ` {{ value }} ` | The current invalid value |
54+ | ` {{ name }} ` | Name of the invalid value |
55+ | ` {{ code }} ` | Selected code type |
You can’t perform that action at this time.
0 commit comments