From 4f97f62ccf39cc23bfe363aad7eaa58ef0426636 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Fri, 25 Apr 2025 15:31:08 +0330 Subject: [PATCH 1/8] More compatible regex for mobile numbers --- src/Utils/CountryPhoneValidator/IRPhoneValidator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils/CountryPhoneValidator/IRPhoneValidator.php b/src/Utils/CountryPhoneValidator/IRPhoneValidator.php index 0889e6f..60fb6a4 100644 --- a/src/Utils/CountryPhoneValidator/IRPhoneValidator.php +++ b/src/Utils/CountryPhoneValidator/IRPhoneValidator.php @@ -9,6 +9,6 @@ class IRPhoneValidator implements CountryPhoneValidator */ public function validate($value): bool { - return preg_match('/^(\+98|0)?9\d{9}$/', $value); + return preg_match('/^(\+98|98|0098|0)?9\d{9}$/', $value); } } From 17ced059b21b8b81fc4e9431fc2eed089fa4ae1a Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Fri, 25 Apr 2025 15:32:04 +0330 Subject: [PATCH 2/8] Add Iran License Plate Validator --- tests/Rules/ValidIranPlateTest.php | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/Rules/ValidIranPlateTest.php diff --git a/tests/Rules/ValidIranPlateTest.php b/tests/Rules/ValidIranPlateTest.php new file mode 100644 index 0000000..e8949c3 --- /dev/null +++ b/tests/Rules/ValidIranPlateTest.php @@ -0,0 +1,33 @@ + [new ValidIranPlate]]; + $data = ['iran_plate' => '32 ی 321 ایران 11']; + $passes = $this->app['validator']->make($data, $rules)->passes(); + + $this->assertTrue($passes); + } + + /** + * Test Iran License Plate is not valid. + */ + public function test_iran_plate_is_not_valid() + { + $rules = ['iran_plate' => [new ValidIranPlate]]; + $data = ['iran_plate' => '12 ب 345 ترکیه 67']; + $passes = $this->app['validator']->make($data, $rules)->passes(); + + $this->assertFalse($passes); + } +} From 401e9ad5356354e70f45cfde954ab3ad36b3b5c9 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Fri, 25 Apr 2025 15:32:36 +0330 Subject: [PATCH 3/8] Revert "Add Iran License Plate Validator" This reverts commit 17ced059b21b8b81fc4e9431fc2eed089fa4ae1a. --- tests/Rules/ValidIranPlateTest.php | 33 ------------------------------ 1 file changed, 33 deletions(-) delete mode 100644 tests/Rules/ValidIranPlateTest.php diff --git a/tests/Rules/ValidIranPlateTest.php b/tests/Rules/ValidIranPlateTest.php deleted file mode 100644 index e8949c3..0000000 --- a/tests/Rules/ValidIranPlateTest.php +++ /dev/null @@ -1,33 +0,0 @@ - [new ValidIranPlate]]; - $data = ['iran_plate' => '32 ی 321 ایران 11']; - $passes = $this->app['validator']->make($data, $rules)->passes(); - - $this->assertTrue($passes); - } - - /** - * Test Iran License Plate is not valid. - */ - public function test_iran_plate_is_not_valid() - { - $rules = ['iran_plate' => [new ValidIranPlate]]; - $data = ['iran_plate' => '12 ب 345 ترکیه 67']; - $passes = $this->app['validator']->make($data, $rules)->passes(); - - $this->assertFalse($passes); - } -} From c58089519dba99bb1e9ba569efcff9daa07c91ec Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Fri, 25 Apr 2025 15:43:00 +0330 Subject: [PATCH 4/8] Add rule for Iran license plate --- src/Rules/ValidIranPlate.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/Rules/ValidIranPlate.php diff --git a/src/Rules/ValidIranPlate.php b/src/Rules/ValidIranPlate.php new file mode 100644 index 0000000..fc5b16f --- /dev/null +++ b/src/Rules/ValidIranPlate.php @@ -0,0 +1,24 @@ + Date: Fri, 25 Apr 2025 15:44:46 +0330 Subject: [PATCH 5/8] Update language translations files --- src/lang/It/validate.php | 2 ++ src/lang/ar/validate.php | 2 ++ src/lang/az/validate.php | 2 ++ src/lang/bn/validate.php | 2 ++ src/lang/ca/validate.php | 2 ++ src/lang/de/validate.php | 1 + src/lang/el/validate.php | 2 ++ src/lang/en/validate.php | 2 ++ src/lang/es/validate.php | 2 ++ src/lang/fa/validate.php | 1 + src/lang/fr/validate.php | 2 ++ src/lang/hi/validate.php | 2 ++ src/lang/id/validate.php | 2 ++ src/lang/ja/validate.php | 2 ++ src/lang/ko/validate.php | 2 ++ src/lang/ku_so/validate.php | 2 ++ src/lang/mk/validate.php | 2 ++ src/lang/nl/validate.php | 2 ++ src/lang/pt_BR/validate.php | 2 ++ src/lang/ru/validate.php | 2 ++ src/lang/si/validate.php | 2 ++ src/lang/sv/validate.php | 2 ++ src/lang/tr/validate.php | 2 ++ src/lang/uk/validate.php | 2 ++ src/lang/zh_CN/validate.php | 2 ++ 25 files changed, 48 insertions(+) diff --git a/src/lang/It/validate.php b/src/lang/It/validate.php index 70bde03..305c3ac 100644 --- a/src/lang/It/validate.php +++ b/src/lang/It/validate.php @@ -40,4 +40,6 @@ 'url' => ':attribute non è valido.', 'username' => ':attribute non è valido.', 'uuid' => ':attribute non è valido.', + 'landline-number' => ':attribute non è valido.', + 'iran-plate' => ':attribute non è valido.', ]; diff --git a/src/lang/ar/validate.php b/src/lang/ar/validate.php index cc14c54..2620938 100644 --- a/src/lang/ar/validate.php +++ b/src/lang/ar/validate.php @@ -40,4 +40,6 @@ 'url' => ':attribute غير صالح.', 'username' => ':attribute غير صالح.', 'uuid' => ':attribute غير صالح.', + 'landline-number' => ':attribute غير صالح.', + 'iran-plate' => ':attribute غير صالح.', ]; diff --git a/src/lang/az/validate.php b/src/lang/az/validate.php index 10e9f73..c1c9e19 100644 --- a/src/lang/az/validate.php +++ b/src/lang/az/validate.php @@ -40,4 +40,6 @@ 'url' => ':attribute doğru deyil.', 'username' => ':attribute doğru deyil.', 'uuid' => ':attribute doğru deyil.', + 'landline-number' => ':attribute doğru deyil.', + 'iran-plate' => ':attribute doğru deyil.', ]; diff --git a/src/lang/bn/validate.php b/src/lang/bn/validate.php index b198a3e..9542289 100644 --- a/src/lang/bn/validate.php +++ b/src/lang/bn/validate.php @@ -40,4 +40,6 @@ 'url' => ':attribute বৈধ নয়.', 'username' => ':attribute বৈধ নয়.', 'uuid' => ':attribute বৈধ নয়.', + 'landline-number' => ':attribute বৈধ নয়.', + 'iran-plate' => ':attribute বৈধ নয়.', ]; diff --git a/src/lang/ca/validate.php b/src/lang/ca/validate.php index 95f7969..e701bbd 100644 --- a/src/lang/ca/validate.php +++ b/src/lang/ca/validate.php @@ -40,4 +40,6 @@ 'url' => ':attribute no és vàlid.', 'username' => ':attribute no és vàlid.', 'uuid' => ':attribute no és vàlid.', + 'landline-number' => ':attribute no és vàlid.', + 'iran-plate' => ':attribute no és vàlid.', ]; diff --git a/src/lang/de/validate.php b/src/lang/de/validate.php index ec52cee..1c43b93 100644 --- a/src/lang/de/validate.php +++ b/src/lang/de/validate.php @@ -41,4 +41,5 @@ 'username' => ':attribute kein gültiger.', 'uuid' => ':attribute kein gültiger.', 'landline-number' => ':attribute kein gültiger.', + 'iran-plate' => ':attribute kein gültiger.', ]; diff --git a/src/lang/el/validate.php b/src/lang/el/validate.php index 0c59ac0..b738219 100644 --- a/src/lang/el/validate.php +++ b/src/lang/el/validate.php @@ -40,4 +40,6 @@ 'url' => 'Το :attribute δεν είναι έγκυρο.', 'username' => 'Το :attribute δεν είναι έγκυρο.', 'uuid' => 'Το :attribute δεν είναι έγκυρο.', + 'landline-number' => 'Το :attribute δεν είναι έγκυρο.', + 'iran-plate' => 'Το :attribute δεν είναι έγκυρο.', ]; diff --git a/src/lang/en/validate.php b/src/lang/en/validate.php index 907315c..d20e961 100644 --- a/src/lang/en/validate.php +++ b/src/lang/en/validate.php @@ -40,4 +40,6 @@ 'url' => 'The :attribute is not valid.', 'username' => 'The :attribute is not valid.', 'uuid' => 'The :attribute is not valid.', + 'landline-number' => 'The :attribute is not valid.', + 'iran-plate' => 'The :attribute is not valid.', ]; diff --git a/src/lang/es/validate.php b/src/lang/es/validate.php index 923f4a3..6d5c66f 100644 --- a/src/lang/es/validate.php +++ b/src/lang/es/validate.php @@ -40,4 +40,6 @@ 'url' => ':attribute no es válido.', 'username' => ':attribute no es válido.', 'uuid' => ':attribute no es válido.', + 'landline-number' => ':attribute no es válido.', + 'iran-plate' => ':attribute no es válido.', ]; diff --git a/src/lang/fa/validate.php b/src/lang/fa/validate.php index c3f1810..f6b840c 100644 --- a/src/lang/fa/validate.php +++ b/src/lang/fa/validate.php @@ -41,4 +41,5 @@ 'username' => 'مقدار :attribute صحیح نمی باشد.', 'uuid' => 'مقدار :attribute صحیح نمی باشد.', 'landline-number' => 'مقدار :attribute صحیح نمی باشد.', + 'iran-plate' => 'مقدار :attribute صحیح نمی باشد.', ]; diff --git a/src/lang/fr/validate.php b/src/lang/fr/validate.php index b34fc3d..83ab93f 100644 --- a/src/lang/fr/validate.php +++ b/src/lang/fr/validate.php @@ -40,4 +40,6 @@ 'url' => ":attribute n'est pas valide.", 'username' => ":attribute n'est pas valide.", 'uuid' => ":attribute n'est pas valide.", + 'landline-number' => ":attribute n'est pas valide.", + 'iran-plate' => ":attribute n'est pas valide.", ]; diff --git a/src/lang/hi/validate.php b/src/lang/hi/validate.php index a0c6577..3905edd 100644 --- a/src/lang/hi/validate.php +++ b/src/lang/hi/validate.php @@ -40,4 +40,6 @@ 'url' => ':attributeमान्य नहीं है।.', 'username' => ':attributeमान्य नहीं है।.', 'uuid' => ':attributeमान्य नहीं है।.', + 'landline-number' => ':attributeमान्य नहीं है।.', + 'iran-plate' => ':attributeमान्य नहीं है।.', ]; diff --git a/src/lang/id/validate.php b/src/lang/id/validate.php index e53db54..8597f5b 100644 --- a/src/lang/id/validate.php +++ b/src/lang/id/validate.php @@ -40,4 +40,6 @@ 'url' => ':Attribute tidak valid.', 'username' => ':Attribute tidak valid.', 'uuid' => ':Attribute tidak valid.', + 'landline-number' => ':Attribute tidak valid.', + 'iran-plate' => ':Attribute tidak valid.', ]; diff --git a/src/lang/ja/validate.php b/src/lang/ja/validate.php index ef54429..279ecb7 100644 --- a/src/lang/ja/validate.php +++ b/src/lang/ja/validate.php @@ -40,4 +40,6 @@ 'url' => ':attribute有効じゃない。', 'username' => ':attribute有効じゃない。', 'uuid' => ':attribute有効じゃない。', + 'landline-number' => ':attribute有効じゃない。', + 'iran-plate' => ':attribute有効じゃない。', ]; diff --git a/src/lang/ko/validate.php b/src/lang/ko/validate.php index 929d8ee..cf49764 100644 --- a/src/lang/ko/validate.php +++ b/src/lang/ko/validate.php @@ -40,4 +40,6 @@ 'url' => ':attribute유효하지 않습니다.', 'username' => ':attribute유효하지 않습니다.', 'uuid' => ':attribute유효하지 않습니다.', + 'landline-number' => ':attribute유효하지 않습니다.', + 'iran-plate' => ':attribute유효하지 않습니다.', ]; diff --git a/src/lang/ku_so/validate.php b/src/lang/ku_so/validate.php index cddf0a7..f3b1f0a 100644 --- a/src/lang/ku_so/validate.php +++ b/src/lang/ku_so/validate.php @@ -40,4 +40,6 @@ 'url' => 'ئەو :attribute هەڵبژێردراوە نادروستە.', 'username' => 'ئەو :attribute هەڵبژێردراوە نادروستە.', 'uuid' => 'ئەو :attribute هەڵبژێردراوە نادروستە.', + 'landline-number' => 'ئەو :attribute هەڵبژێردراوە نادروستە.', + 'iran-plate' => 'ئەو :attribute هەڵبژێردراوە نادروستە.', ]; diff --git a/src/lang/mk/validate.php b/src/lang/mk/validate.php index fd9e2b2..bff3926 100644 --- a/src/lang/mk/validate.php +++ b/src/lang/mk/validate.php @@ -40,4 +40,6 @@ 'url' => 'Невалидна вредност :attribute', 'username' => 'Невалидна вредност :attribute', 'uuid' => 'Невалидна вредност :attribute', + 'landline-number' => 'Невалидна вредност :attribute', + 'iran-plate' => 'Невалидна вредност :attribute', ]; diff --git a/src/lang/nl/validate.php b/src/lang/nl/validate.php index 85bdd8a..1d57a88 100644 --- a/src/lang/nl/validate.php +++ b/src/lang/nl/validate.php @@ -40,4 +40,6 @@ 'url' => 'De :attribute is niet geldig.', 'username' => 'De :attribute is niet geldig.', 'uuid' => 'De :attribute is niet geldig.', + 'landline-number' => 'De :attribute is niet geldig.', + 'iran-plate' => 'De :attribute is niet geldig.', ]; diff --git a/src/lang/pt_BR/validate.php b/src/lang/pt_BR/validate.php index b2debbb..bec498e 100644 --- a/src/lang/pt_BR/validate.php +++ b/src/lang/pt_BR/validate.php @@ -40,4 +40,6 @@ 'url' => 'O :attribute não é válido.', 'username' => 'O :attribute não é válido.', 'uuid' => 'O :attribute não é válido.', + 'landline-number' => 'O :attribute não é válido.', + 'iran-plate' => 'O :attribute não é válido.', ]; diff --git a/src/lang/ru/validate.php b/src/lang/ru/validate.php index befcc69..ede5f97 100644 --- a/src/lang/ru/validate.php +++ b/src/lang/ru/validate.php @@ -40,4 +40,6 @@ 'url' => ':attribute не действует.', 'username' => ':attribute не действует.', 'uuid' => ':attribute не действует.', + 'landline-number' => ':attribute не действует.', + 'iran-plate' => ':attribute не действует.', ]; diff --git a/src/lang/si/validate.php b/src/lang/si/validate.php index 2198a55..9995433 100644 --- a/src/lang/si/validate.php +++ b/src/lang/si/validate.php @@ -40,4 +40,6 @@ 'url' => ':attribute වලංගු නොවේ.', 'username' => ':attribute වලංගු නොවේ.', 'uuid' => ':attribute වලංගු නොවේ.', + 'landline-number' => ':attribute වලංගු නොවේ.', + 'iran-plate' => ':attribute වලංගු නොවේ.', ]; diff --git a/src/lang/sv/validate.php b/src/lang/sv/validate.php index 9e8310f..ce61dc0 100644 --- a/src/lang/sv/validate.php +++ b/src/lang/sv/validate.php @@ -40,4 +40,6 @@ 'url' => 'Värdet :attribute är inte korrekt.', 'username' => 'Värdet :attribute är inte korrekt.', 'uuid' => 'Värdet :attribute är inte korrekt.', + 'landline-number' => 'Värdet :attribute är inte korrekt.', + 'iran-plate' => 'Värdet :attribute är inte korrekt.', ]; diff --git a/src/lang/tr/validate.php b/src/lang/tr/validate.php index 7b40e7f..75ec2d8 100644 --- a/src/lang/tr/validate.php +++ b/src/lang/tr/validate.php @@ -40,4 +40,6 @@ 'url' => ':attribute doğru değil.', 'username' => ':attribute doğru değil.', 'uuid' => ':attribute doğru değil.', + 'landline-number' => ':attribute doğru değil.', + 'iran-plate' => ':attribute doğru değil.', ]; diff --git a/src/lang/uk/validate.php b/src/lang/uk/validate.php index aafb4c5..c8f61ee 100644 --- a/src/lang/uk/validate.php +++ b/src/lang/uk/validate.php @@ -40,4 +40,6 @@ 'url' => ':attribute не є дійсним.', 'username' => ':attribute не є дійсним.', 'uuid' => ':attribute не є дійсним.', + 'landline-number' => ':attribute не є дійсним.', + 'iran-plate' => ':attribute не є дійсним.', ]; diff --git a/src/lang/zh_CN/validate.php b/src/lang/zh_CN/validate.php index 6768cd8..f6cd6b5 100644 --- a/src/lang/zh_CN/validate.php +++ b/src/lang/zh_CN/validate.php @@ -40,4 +40,6 @@ 'url' => ':attribute无效.', 'username' => ':attribute无效.', 'uuid' => ':attribute无效.', + 'landline-number' => ':attribute无效.', + 'iran-plate' => ':attribute无效.', ]; From c8243070f1ad0029d70c9cb62005d1c7da9d614b Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Fri, 25 Apr 2025 15:44:51 +0330 Subject: [PATCH 6/8] Test for Iran license plate --- tests/Rules/ValidIranPlateTest.php | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/Rules/ValidIranPlateTest.php diff --git a/tests/Rules/ValidIranPlateTest.php b/tests/Rules/ValidIranPlateTest.php new file mode 100644 index 0000000..a1b8d74 --- /dev/null +++ b/tests/Rules/ValidIranPlateTest.php @@ -0,0 +1,33 @@ + [new ValidIranPlate]]; + $data = ['car_number' => '32 ی 321 ایران 45']; + $passes = $this->app['validator']->make($data, $rules)->passes(); + + $this->assertTrue($passes); + } + + /** + * Test iran license plate is not valid. + */ + public function test_iran_plate_is_not_valid() + { + $rules = ['car_number' => [new ValidIranPlate]]; + $data = ['car_number' => '32 ی 321 ترکیه 45']; + $passes = $this->app['validator']->make($data, $rules)->passes(); + + $this->assertFalse($passes); + } +} From 2ff5b5f33a92ec761dd3d055e6931d4eaae14505 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Fri, 25 Apr 2025 15:54:38 +0330 Subject: [PATCH 7/8] Add documentation for Iran car license plate --- docs/1.x/valid-iran-plate.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 docs/1.x/valid-iran-plate.md diff --git a/docs/1.x/valid-iran-plate.md b/docs/1.x/valid-iran-plate.md new file mode 100644 index 0000000..0e01eb8 --- /dev/null +++ b/docs/1.x/valid-iran-plate.md @@ -0,0 +1,15 @@ +## ValidIranPlate + +If you want to validate the Iran license plate number, you can use the `ValidIranPlate` rule: + +```php +use Milwad\LaravelValidate\Rules\ValidIranPlate; + +return [ + 'car-plate-number' => ['required', new ValidCarNumber()], + /* + * Iran plate license number: + * 32 ی 321 ایران 45 + */ +]; +``` From 0d9b01b0090b70349333ee03d94889a3ca6dac43 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Fri, 25 Apr 2025 15:55:04 +0330 Subject: [PATCH 8/8] Update readme for Iran car license plate --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a8f7522..5b7cd16 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ return [ | 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) | | 40 | [ValidVatId](https://github.com/milwad-dev/laravel-validate/blob/1.x/docs/1.x/valid-vatid.md) | Validate european VAT ID ex (EL123456789123) | | 41 | [ValidLandlineNumber](https://github.com/milwad-dev/laravel-validate/blob/1.x/docs/1.x/valid-landline-number.md) | Validate landline number | +| 42 | [ValidIranPlate](https://github.com/milwad-dev/laravel-validate/blob/1.x/docs/1.x/valid-iran-plate.md) | Validate Iran car license plate |