Skip to content

Commit 44c2ca2

Browse files
authored
Merge pull request #5 from vahidkaargar/dev
Add validation for Iran car license plate
2 parents c2b8fd8 + 0d9b01b commit 44c2ca2

30 files changed

+122
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ return [
138138
| 39 | [ValidUuid](https://github.com/milwad-dev/laravel-validate/blob/1.x/docs/1.x/valid-uuid.md) | Validate uuid for ex (123e4567-e89b-12d3-a456-426655440000) |
139139
| 40 | [ValidVatId](https://github.com/milwad-dev/laravel-validate/blob/1.x/docs/1.x/valid-vatid.md) | Validate european VAT ID ex (EL123456789123) |
140140
| 41 | [ValidLandlineNumber](https://github.com/milwad-dev/laravel-validate/blob/1.x/docs/1.x/valid-landline-number.md) | Validate landline number |
141+
| 42 | [ValidIranPlate](https://github.com/milwad-dev/laravel-validate/blob/1.x/docs/1.x/valid-iran-plate.md) | Validate Iran car license plate |
141142

142143
<a name="support-languages"></a>
143144

docs/1.x/valid-iran-plate.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## ValidIranPlate
2+
3+
If you want to validate the Iran license plate number, you can use the `ValidIranPlate` rule:
4+
5+
```php
6+
use Milwad\LaravelValidate\Rules\ValidIranPlate;
7+
8+
return [
9+
'car-plate-number' => ['required', new ValidCarNumber()],
10+
/*
11+
* Iran plate license number:
12+
* 32 ی 321 ایران 45
13+
*/
14+
];
15+
```

src/Rules/ValidIranPlate.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Milwad\LaravelValidate\Rules;
4+
5+
use Illuminate\Contracts\Validation\Rule;
6+
7+
class ValidIranPlate implements Rule
8+
{
9+
/**
10+
* Check License Plate Validator.
11+
*/
12+
public function passes($attribute, $value): bool
13+
{
14+
return preg_match("/^\d{2}\s?[آ-ی]\s?\d{3}\s?ایران\s?\d{2}$/u", $value);
15+
}
16+
17+
/**
18+
* Get the License Plate Validator error message.
19+
*/
20+
public function message(): string
21+
{
22+
return __('validate.iran-plate');
23+
}
24+
}

src/Utils/CountryPhoneValidator/IRPhoneValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ class IRPhoneValidator implements CountryPhoneValidator
99
*/
1010
public function validate($value): bool
1111
{
12-
return preg_match('/^(\+98|0)?9\d{9}$/', $value);
12+
return preg_match('/^(\+98|98|0098|0)?9\d{9}$/', $value);
1313
}
1414
}

src/lang/It/validate.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@
4040
'url' => ':attribute non è valido.',
4141
'username' => ':attribute non è valido.',
4242
'uuid' => ':attribute non è valido.',
43+
'landline-number' => ':attribute non è valido.',
44+
'iran-plate' => ':attribute non è valido.',
4345
];

src/lang/ar/validate.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@
4040
'url' => ':attribute غير صالح.',
4141
'username' => ':attribute غير صالح.',
4242
'uuid' => ':attribute غير صالح.',
43+
'landline-number' => ':attribute غير صالح.',
44+
'iran-plate' => ':attribute غير صالح.',
4345
];

src/lang/az/validate.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@
4040
'url' => ':attribute doğru deyil.',
4141
'username' => ':attribute doğru deyil.',
4242
'uuid' => ':attribute doğru deyil.',
43+
'landline-number' => ':attribute doğru deyil.',
44+
'iran-plate' => ':attribute doğru deyil.',
4345
];

src/lang/bn/validate.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@
4040
'url' => ':attribute বৈধ নয়.',
4141
'username' => ':attribute বৈধ নয়.',
4242
'uuid' => ':attribute বৈধ নয়.',
43+
'landline-number' => ':attribute বৈধ নয়.',
44+
'iran-plate' => ':attribute বৈধ নয়.',
4345
];

src/lang/ca/validate.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@
4040
'url' => ':attribute no és vàlid.',
4141
'username' => ':attribute no és vàlid.',
4242
'uuid' => ':attribute no és vàlid.',
43+
'landline-number' => ':attribute no és vàlid.',
44+
'iran-plate' => ':attribute no és vàlid.',
4345
];

src/lang/de/validate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@
4141
'username' => ':attribute kein gültiger.',
4242
'uuid' => ':attribute kein gültiger.',
4343
'landline-number' => ':attribute kein gültiger.',
44+
'iran-plate' => ':attribute kein gültiger.',
4445
];

0 commit comments

Comments
 (0)