From 08a799081dd66506493243e155ac9ec3c017e6b0 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Thu, 17 Apr 2025 16:51:22 +0330 Subject: [PATCH 01/17] Create CountryLandlineValidator interface --- .../CountryLandlineValidator/CountryLandlineValidator.php | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/Utils/CountryLandlineValidator/CountryLandlineValidator.php diff --git a/src/Utils/CountryLandlineValidator/CountryLandlineValidator.php b/src/Utils/CountryLandlineValidator/CountryLandlineValidator.php new file mode 100644 index 0000000..d2a3f6c --- /dev/null +++ b/src/Utils/CountryLandlineValidator/CountryLandlineValidator.php @@ -0,0 +1,8 @@ + Date: Thu, 17 Apr 2025 16:53:02 +0330 Subject: [PATCH 02/17] Create CountryLandlineCallback class --- src/Utils/CountryLandlineCallback.php | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/Utils/CountryLandlineCallback.php diff --git a/src/Utils/CountryLandlineCallback.php b/src/Utils/CountryLandlineCallback.php new file mode 100644 index 0000000..a7c7292 --- /dev/null +++ b/src/Utils/CountryLandlineCallback.php @@ -0,0 +1,40 @@ +validate($value); + } else { + throw new \BadMethodCallException("Validator method for '$code' does not exist."); + } + } +} From c7f4cfe4070871b0e88a6bcb97578388f5b1d773 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Thu, 17 Apr 2025 16:53:29 +0330 Subject: [PATCH 03/17] Create landline validator for germany --- .../DELandlineValidator.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/Utils/CountryLandlineValidator/DELandlineValidator.php diff --git a/src/Utils/CountryLandlineValidator/DELandlineValidator.php b/src/Utils/CountryLandlineValidator/DELandlineValidator.php new file mode 100644 index 0000000..a6a9605 --- /dev/null +++ b/src/Utils/CountryLandlineValidator/DELandlineValidator.php @@ -0,0 +1,14 @@ + Date: Thu, 17 Apr 2025 16:53:51 +0330 Subject: [PATCH 04/17] Create landline validator for Iran --- .../IRLandlineValidator.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/Utils/CountryLandlineValidator/IRLandlineValidator.php diff --git a/src/Utils/CountryLandlineValidator/IRLandlineValidator.php b/src/Utils/CountryLandlineValidator/IRLandlineValidator.php new file mode 100644 index 0000000..1212a0e --- /dev/null +++ b/src/Utils/CountryLandlineValidator/IRLandlineValidator.php @@ -0,0 +1,14 @@ + Date: Thu, 17 Apr 2025 16:55:25 +0330 Subject: [PATCH 05/17] Create ValidLandlineNumber.php --- src/Rules/ValidLandlineNumber.php | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/Rules/ValidLandlineNumber.php diff --git a/src/Rules/ValidLandlineNumber.php b/src/Rules/ValidLandlineNumber.php new file mode 100644 index 0000000..ca29a0a --- /dev/null +++ b/src/Rules/ValidLandlineNumber.php @@ -0,0 +1,33 @@ +code)) { + $passes = CountryLandlineCallback::callLandlineValidator($this->code, $value); + + return collect($passes)->some(fn ($passe) => $passe); + } + + return preg_match('/^(?:\+|00)(?:[1-9]\d{0,2})(?:[ .\-]?\(?\d+\)?)+$/', $value); + } + + /** + * Get the validation error message. + */ + public function message(): string + { + return __('validate.landline-number'); + } +} From 814e5373dc072f5cef0e9cdd16b10e0d082d3eb5 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Thu, 17 Apr 2025 16:56:02 +0330 Subject: [PATCH 06/17] Add translation for landline validation --- src/lang/de/validate.php | 1 + src/lang/fa/validate.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/lang/de/validate.php b/src/lang/de/validate.php index 59bc605..ec52cee 100644 --- a/src/lang/de/validate.php +++ b/src/lang/de/validate.php @@ -40,4 +40,5 @@ 'url' => ':attribute kein gültiger.', 'username' => ':attribute kein gültiger.', 'uuid' => ':attribute kein gültiger.', + 'landline-number' => ':attribute kein gültiger.', ]; diff --git a/src/lang/fa/validate.php b/src/lang/fa/validate.php index 72975fb..c3f1810 100644 --- a/src/lang/fa/validate.php +++ b/src/lang/fa/validate.php @@ -40,4 +40,5 @@ 'url' => 'مقدار :attribute صحیح نمی باشد.', 'username' => 'مقدار :attribute صحیح نمی باشد.', 'uuid' => 'مقدار :attribute صحیح نمی باشد.', + 'landline-number' => 'مقدار :attribute صحیح نمی باشد.', ]; From c7f7dfe8cadb1f7f41740483aec6619c092a9e27 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Thu, 17 Apr 2025 16:56:22 +0330 Subject: [PATCH 07/17] Add landline validators to config --- config/laravel-validate.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/laravel-validate.php b/config/laravel-validate.php index 196f2cc..c7989e1 100644 --- a/config/laravel-validate.php +++ b/config/laravel-validate.php @@ -18,6 +18,8 @@ use Milwad\LaravelValidate\Utils\CountryPhoneValidator\SEPhoneValidator; use Milwad\LaravelValidate\Utils\CountryPhoneValidator\TRPhoneValidator; use Milwad\LaravelValidate\Utils\CountryPhoneValidator\ZHPhoneValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\IRLandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\DELandlineValidator; return [ /* @@ -47,6 +49,17 @@ 'ZH' => ZHPhoneValidator::class, // China ], + /* + * Mapping of country codes to their respective landline number validator classes. + * Each validator enforces country-specific landline number formatting and validation rules. + * + * You can add custom country landline validator. + */ + 'landline-country' => [ + 'DE' => DELandlineValidator::class, // Germany + 'IR' => IRLandlineValidator::class, // Iran + ], + /* * If you want to use rules like 'required|ValidPhone' in your validations, you can change it to true. */ From ed58f14d7bea7b1bd6c640f9b8ceccd396dfc187 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Thu, 17 Apr 2025 16:57:05 +0330 Subject: [PATCH 08/17] Add landline validators on service provider --- src/LaravelValidateServiceProvider.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/LaravelValidateServiceProvider.php b/src/LaravelValidateServiceProvider.php index 0c5d87f..569a86f 100644 --- a/src/LaravelValidateServiceProvider.php +++ b/src/LaravelValidateServiceProvider.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Validator; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Str; +use Milwad\LaravelValidate\Utils\CountryLandlineCallback; use Milwad\LaravelValidate\Utils\CountryPhoneCallback; class LaravelValidateServiceProvider extends ServiceProvider @@ -65,6 +66,12 @@ public function boot(): void CountryPhoneCallback::addValidator($code, $country); } + $landlineCountries = config('laravel-validate.landline-country', []); + + foreach ($landlineCountries as $code => $country) { + CountryLandlineCallback::addValidator($code, $country); + } + // Register rules in container if (config('laravel-validate.using_container', false)) { $rules = File::files(__DIR__.'/Rules'); From db17be5e674ca0f8988c170c6ba49b29812157d2 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Thu, 17 Apr 2025 16:57:23 +0330 Subject: [PATCH 09/17] Create test for landline validator --- tests/Rules/ValidLandlineNumberTest.php | 79 +++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 tests/Rules/ValidLandlineNumberTest.php diff --git a/tests/Rules/ValidLandlineNumberTest.php b/tests/Rules/ValidLandlineNumberTest.php new file mode 100644 index 0000000..628dee9 --- /dev/null +++ b/tests/Rules/ValidLandlineNumberTest.php @@ -0,0 +1,79 @@ + [new ValidLandlineNumber], + 'landline_de' => [new ValidLandlineNumber(Country::GERMANY)], + ]; + $data = [ + 'landline_number' => '+98212223343', + 'landline_de' => '+49301234567', + ]; + $passes = $this->app['validator']->make($data, $rules)->passes(); + + $this->assertTrue($passes); + } + + /** + * Test landline number is not valid. + */ + public function test_landline_number_is_not_valid() + { + $rules = [ + 'landline_number' => [new ValidLandlineNumber], + 'landline_ir' => [new ValidLandlineNumber(Country::IRAN)], + ]; + $data = [ + 'landline_number' => '123456789', + 'landline_ir' => '09120000000', + ]; + $passes = $this->app['validator']->make($data, $rules)->passes(); + + $this->assertFalse($passes); + } + + /** + * Test all landline number is valid by specific code. + */ + public function test_all_landline_number_is_valid_by_specific_code() + { + $rules = [ + 'landline_ir' => [new ValidLandlineNumber(Country::IRAN)], + 'landline_de' => [new ValidLandlineNumber(Country::GERMANY)], + ]; + $data = [ + 'landline_ir' => '02132223343', + 'landline_de' => '+49301234567', + ]; + $passes = $this->app['validator']->make($data, $rules)->passes(); + + $this->assertTrue($passes); + } + + /** + * Test if landline number validate method is not exists, will be thrown an exception. + */ + public function test_if_landline_number_validate_method_is_not_exists() + { + $this->expectException(BadMethodCallException::class); + $this->expectExceptionMessage("Validator method for 'AZ' does not exist."); + + $rules = ['landline' => [new ValidLandlineNumber(Country::AZERBAIJAN)]]; + $data = ['landline' => '+62812345678']; + + $this->app['validator']->make($data, $rules)->passes(); + } +} From 704fc4be9046f1ca4e28a9ad171e1f80c9eeba14 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Thu, 17 Apr 2025 16:57:44 +0330 Subject: [PATCH 10/17] Create documentation for landline validator --- docs/1.x/valid-landline-number.md | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 docs/1.x/valid-landline-number.md diff --git a/docs/1.x/valid-landline-number.md b/docs/1.x/valid-landline-number.md new file mode 100644 index 0000000..60c6cbd --- /dev/null +++ b/docs/1.x/valid-landline-number.md @@ -0,0 +1,33 @@ +## ValidLandlineNumber + +If you want to validate the landline number, you can use the `ValidLandlineNumber` rule: + +```php +use Milwad\LaravelValidate\Rules\ValidLandlineNumber; + +return [ + 'landline-number' => ['required', new ValidLandlineNumber()], // landline-number => 09120000000 +]; +``` + +Also `ValidLandlineNumber` have the ability to validate landline number with specific country code: + +```php +use Milwad\LaravelValidate\Rules\ValidLandlineNumber; +use Milwad\LaravelValidate\Utils\Country; + +return [ + 'landline-number' => ['required', new ValidLandlineNumber(Country::GERMANY)], // landline-number => 09120000000 +]; +``` + +> **Note** +> If you want to know which country's codes are supported by the `ValidLandlineNumber` Rule, you can search your country +> on this [Countries Landline Number](#support-countries-landline-number) list. + + +## Support Countries Landline Number + +- ✅ IRAN +- ✅ GERMANY + From 7615da2f3dee8e8a1725319b7b18320c0d25c27a Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Thu, 17 Apr 2025 16:58:12 +0330 Subject: [PATCH 11/17] Add landline validator documentation to readme.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bf60fb8..a8f7522 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ return [ | 38 | [ValidUsername](https://github.com/milwad-dev/laravel-validate/blob/1.x/docs/1.x/valid-username.md) | Validate username for ex (milwad) | | 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 | From 954e02a821e71935b866df474d3d195dba5d77d7 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Sat, 19 Apr 2025 12:30:36 +0330 Subject: [PATCH 12/17] Support 18 countries for landline validation --- .../CMLandlineValidator.php | 14 ++++++++++++++ .../ENLandlineValidator.php | 14 ++++++++++++++ .../ESLandlineValidator.php | 14 ++++++++++++++ .../FRLandlineValidator.php | 14 ++++++++++++++ .../GRLandlineValidator.php | 14 ++++++++++++++ .../IDLandlineValidator.php | 14 ++++++++++++++ .../INLandlineValidator.php | 14 ++++++++++++++ .../ITLandlineValidator.php | 14 ++++++++++++++ .../JALandlineValidator.php | 14 ++++++++++++++ .../KOLandlineValidator.php | 14 ++++++++++++++ .../NELandlineValidator.php | 14 ++++++++++++++ .../RULandlineValidator.php | 14 ++++++++++++++ .../SALandlineValidator.php | 14 ++++++++++++++ .../SELandlineValidator.php | 14 ++++++++++++++ .../TRLandlineValidator.php | 14 ++++++++++++++ .../ZHLandlineValidator.php | 14 ++++++++++++++ 16 files changed, 224 insertions(+) create mode 100644 src/Utils/CountryLandlineValidator/CMLandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/ENLandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/ESLandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/FRLandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/GRLandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/IDLandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/INLandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/ITLandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/JALandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/KOLandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/NELandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/RULandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/SALandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/SELandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/TRLandlineValidator.php create mode 100644 src/Utils/CountryLandlineValidator/ZHLandlineValidator.php diff --git a/src/Utils/CountryLandlineValidator/CMLandlineValidator.php b/src/Utils/CountryLandlineValidator/CMLandlineValidator.php new file mode 100644 index 0000000..4090d7c --- /dev/null +++ b/src/Utils/CountryLandlineValidator/CMLandlineValidator.php @@ -0,0 +1,14 @@ + Date: Sat, 19 Apr 2025 12:31:10 +0330 Subject: [PATCH 13/17] Add countries to config for landline --- config/laravel-validate.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/config/laravel-validate.php b/config/laravel-validate.php index c7989e1..69f5796 100644 --- a/config/laravel-validate.php +++ b/config/laravel-validate.php @@ -18,8 +18,25 @@ use Milwad\LaravelValidate\Utils\CountryPhoneValidator\SEPhoneValidator; use Milwad\LaravelValidate\Utils\CountryPhoneValidator\TRPhoneValidator; use Milwad\LaravelValidate\Utils\CountryPhoneValidator\ZHPhoneValidator; -use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\IRLandlineValidator; + +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\CMLandlineValidator; use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\DELandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\ENLandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\ESLandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\FRLandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\GRLandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\IDLandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\INLandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\IRLandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\ITLandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\JALandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\KOLandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\NELandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\RULandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\SALandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\SELandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\TRLandlineValidator; +use \Milwad\LaravelValidate\Utils\CountryLandlineValidator\ZHLandlineValidator; return [ /* @@ -56,8 +73,24 @@ * You can add custom country landline validator. */ 'landline-country' => [ + 'CM' => CMLandlineValidator::class, // Cameroon 'DE' => DELandlineValidator::class, // Germany + 'EN' => ENLandlineValidator::class, // England + 'ES' => ESLandlineValidator::class, // Spain + 'FR' => FRLandlineValidator::class, // France + 'GR' => GRLandlineValidator::class, // Greece + 'ID' => IDLandlineValidator::class, // Indonesia + 'IN' => INLandlineValidator::class, // India 'IR' => IRLandlineValidator::class, // Iran + 'IT' => ITLandlineValidator::class, // Italy + 'JA' => JALandlineValidator::class, // Japan + 'KO' => KOLandlineValidator::class, // South Korea + 'NE' => NELandlineValidator::class, // Netherlands + 'RU' => RULandlineValidator::class, // Russia + 'SA' => SALandlineValidator::class, // Saudi Arabia + 'SE' => SELandlineValidator::class, // Sweden + 'TR' => TRLandlineValidator::class, // Turkey + 'ZH' => ZHLandlineValidator::class, // China ], /* From d22d1216b48f3dd191de0f8f9a69c18d88fcb6e0 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Sat, 19 Apr 2025 12:33:53 +0330 Subject: [PATCH 14/17] Update documents for landline validation --- docs/1.x/valid-landline-number.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/1.x/valid-landline-number.md b/docs/1.x/valid-landline-number.md index 60c6cbd..32cd7f2 100644 --- a/docs/1.x/valid-landline-number.md +++ b/docs/1.x/valid-landline-number.md @@ -29,5 +29,20 @@ return [ ## Support Countries Landline Number - ✅ IRAN +- ✅ ENGLAND +- ✅ NIGER +- ✅ SAUDI_ARABIA - ✅ GERMANY - +- ✅ GREECE +- ✅ SPAIN +- ✅ FRANCE +- ✅ INDIA +- ✅ INDONESIA +- ✅ ITALY +- ✅ JAPAN +- ✅ KOREAN +- ✅ RUSSIA +- ✅ SWEDEN +- ✅ TURKEY +- ✅ CHINA +- ✅ CAMEROON From c5a120d00ee59d224541128a06f2ec497025eaee Mon Sep 17 00:00:00 2001 From: Milwad Khosravi <98118400+milwad-dev@users.noreply.github.com> Date: Sat, 19 Apr 2025 23:40:47 +0330 Subject: [PATCH 15/17] Update valid-landline-number.md --- docs/1.x/valid-landline-number.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/1.x/valid-landline-number.md b/docs/1.x/valid-landline-number.md index 32cd7f2..e46f296 100644 --- a/docs/1.x/valid-landline-number.md +++ b/docs/1.x/valid-landline-number.md @@ -6,18 +6,18 @@ If you want to validate the landline number, you can use the `ValidLandlineNumbe use Milwad\LaravelValidate\Rules\ValidLandlineNumber; return [ - 'landline-number' => ['required', new ValidLandlineNumber()], // landline-number => 09120000000 + 'landline-number' => ['required', new ValidLandlineNumber()], // landline-number => +98212223343 ]; ``` -Also `ValidLandlineNumber` have the ability to validate landline number with specific country code: +Also, `ValidLandlineNumber` can validate landline numbers with a specific country code: ```php use Milwad\LaravelValidate\Rules\ValidLandlineNumber; use Milwad\LaravelValidate\Utils\Country; return [ - 'landline-number' => ['required', new ValidLandlineNumber(Country::GERMANY)], // landline-number => 09120000000 + 'landline-number' => ['required', new ValidLandlineNumber(Country::GERMANY)], // landline-number => +49301234567 ]; ``` From a97df2791692dc4ef6bb51f64a61dc994eac3e64 Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Sun, 20 Apr 2025 12:26:37 +0330 Subject: [PATCH 16/17] Fix validation for Saudi Arabia landline --- src/Utils/CountryLandlineValidator/SALandlineValidator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils/CountryLandlineValidator/SALandlineValidator.php b/src/Utils/CountryLandlineValidator/SALandlineValidator.php index ac3325a..c4d216a 100644 --- a/src/Utils/CountryLandlineValidator/SALandlineValidator.php +++ b/src/Utils/CountryLandlineValidator/SALandlineValidator.php @@ -9,6 +9,6 @@ class SALandlineValidator implements CountryLandlineValidator */ public function validate($value): bool { - return preg_match('/^(?:(?:\+966|00966)[\s\-]?1\d{7}|01\d{7})$/', $value); + return preg_match('/^((?:[+?0?0?966]+)(?:\s?\d{2})(?:\s?\d{7}))$/', $value); } } From 5dfd2baaf265bf7f1e306f227d467d7045cc2b7a Mon Sep 17 00:00:00 2001 From: Vahid Kaargar Date: Sun, 20 Apr 2025 12:27:25 +0330 Subject: [PATCH 17/17] Write test for all validations --- tests/Rules/ValidLandlineNumberTest.php | 36 +++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/tests/Rules/ValidLandlineNumberTest.php b/tests/Rules/ValidLandlineNumberTest.php index 628dee9..f73bc24 100644 --- a/tests/Rules/ValidLandlineNumberTest.php +++ b/tests/Rules/ValidLandlineNumberTest.php @@ -52,11 +52,43 @@ public function test_all_landline_number_is_valid_by_specific_code() { $rules = [ 'landline_ir' => [new ValidLandlineNumber(Country::IRAN)], + 'landline_en' => [new ValidLandlineNumber(Country::ENGLAND)], + 'landline_ne' => [new ValidLandlineNumber(Country::NIGER)], + 'landline_sa' => [new ValidLandlineNumber(Country::SAUDI_ARABIA)], 'landline_de' => [new ValidLandlineNumber(Country::GERMANY)], + 'landline_gr' => [new ValidLandlineNumber(Country::GREECE)], + 'landline_es' => [new ValidLandlineNumber(Country::SPAIN)], + 'landline_fr' => [new ValidLandlineNumber(Country::FRANCE)], + 'landline_in' => [new ValidLandlineNumber(Country::INDIA)], + 'landline_id' => [new ValidLandlineNumber(Country::INDONESIA)], + 'landline_it' => [new ValidLandlineNumber(Country::ITALY)], + 'landline_ja' => [new ValidLandlineNumber(Country::JAPAN)], + 'landline_ko' => [new ValidLandlineNumber(Country::KOREAN)], + 'landline_ru' => [new ValidLandlineNumber(Country::RUSSIA)], + 'landline_se' => [new ValidLandlineNumber(Country::SWEDEN)], + 'landline_tr' => [new ValidLandlineNumber(Country::TURKEY)], + 'landline_ch' => [new ValidLandlineNumber(Country::CHINA)], + 'landline_cm' => [new ValidLandlineNumber(Country::CAMEROON)], ]; $data = [ - 'landline_ir' => '02132223343', - 'landline_de' => '+49301234567', + 'landline_ir' => '02155555555', // Iran - Tehran landline + 'landline_en' => '+442071234567', // UK - London landline + 'landline_ne' => '+22720301234', // Niger - Niamey landline + 'landline_sa' => '+966512345678', // Saudi Arabia - Riyadh landline + 'landline_de' => '+493012345678', // Germany - Berlin landline + 'landline_gr' => '+302112345678', // Greece - Athens landline + 'landline_es' => '+34912345678', // Spain - Madrid landline + 'landline_fr' => '+33123456789', // France - Paris landline + 'landline_in' => '+911123456789', // India - Delhi landline + 'landline_id' => '+62211234567', // Indonesia - Jakarta landline + 'landline_it' => '+390612345678', // Italy - Rome landline + 'landline_ja' => '+81312345678', // Japan - Tokyo landline + 'landline_ko' => '+82231234567', // South Korea - Seoul landline + 'landline_ru' => '+74951234567', // Russia - Moscow landline + 'landline_se' => '+46812345678', // Sweden - Stockholm landline + 'landline_tr' => '+902123456789', // Turkey - Istanbul landline + 'landline_ch' => '+861012345678', // China - Beijing landline + 'landline_cm' => '+237222123456', // Cameroon - Douala landline ]; $passes = $this->app['validator']->make($data, $rules)->passes();