Skip to content

Commit 5908f2b

Browse files
committed
Create valid-country.md
1 parent 7d759c8 commit 5908f2b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

docs/1.x/valid-country.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## ValidCountry
2+
3+
If you want to validate the country name, you can use the `ValidCountry` rule:
4+
5+
```php
6+
use Milwad\LaravelValidate\Rules\ValidCountry;
7+
8+
return [
9+
'country' => ['required', new ValidCountry()], // country => United Arab Emirates
10+
];
11+
```
12+
13+
Also, you can validate country name by key like "AE":
14+
15+
```php
16+
use Milwad\LaravelValidate\Rules\ValidCountry;
17+
18+
return [
19+
'country' => ['required', new ValidCountry(validByKey: true)], // country => "AE"
20+
];
21+
```
22+
23+
For see the list of country name, you can open `config/laravel-validate.php`, and go to `countries` key:
24+
25+
```php
26+
/*
27+
* The list of country names.
28+
*
29+
* If any country name is missing from this list, you can add your country name to this array.
30+
*/
31+
'countries' => [...],
32+
```
33+
34+
> If any country name is missing from this list, you can add your country name to this array.

0 commit comments

Comments
 (0)