File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed
src/Utils/CountryPhoneValidator Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ use Milwad \LaravelValidate \Utils \CountryPhoneValidator \CMPhoneValidator ;
3
4
use Milwad \LaravelValidate \Utils \CountryPhoneValidator \DEPhoneValidator ;
4
5
use Milwad \LaravelValidate \Utils \CountryPhoneValidator \ENPhoneValidator ;
5
6
use Milwad \LaravelValidate \Utils \CountryPhoneValidator \ESPhoneValidator ;
26
27
* You can add custom country phone validator.
27
28
*/
28
29
'phone-country ' => [
30
+ 'CM ' => CMPhoneValidator::class, // Cameroon
29
31
'DE ' => DEPhoneValidator::class, // Germany
30
32
'EN ' => ENPhoneValidator::class, // England
31
33
'ES ' => ESPhoneValidator::class, // Spain
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Milwad \LaravelValidate \Utils \CountryPhoneValidator ;
4
+
5
+ class CMPhoneValidator implements CountryPhoneValidator
6
+ {
7
+ public function validate ($ value ): bool
8
+ {
9
+ return preg_match ('/^(?:\+237|00237|237)?[26][256789][0-9]{7}$/ ' , $ value );
10
+ }
11
+ }
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ public function test_all_phone_number_is_valid_by_specific_code()
65
65
'phone_se ' => [new ValidPhoneNumber (Country::SWEDEN )],
66
66
'phone_tr ' => [new ValidPhoneNumber (Country::TURKEY )],
67
67
'phone_ch ' => [new ValidPhoneNumber (Country::CHINA )],
68
+ 'phone_cm ' => [new ValidPhoneNumber (Country::CAMEROON )]
68
69
];
69
70
$ data = [
70
71
'phone_ir ' => '09125555555 ' ,
@@ -84,6 +85,7 @@ public function test_all_phone_number_is_valid_by_specific_code()
84
85
'phone_se ' => '+46701234567 ' ,
85
86
'phone_tr ' => '+905551234567 ' ,
86
87
'phone_ch ' => '+8613812345678 ' ,
88
+ 'phone_cm ' => '+237691234564 '
87
89
];
88
90
$ passes = $ this ->app ['validator ' ]->make ($ data , $ rules )->passes ();
89
91
You can’t perform that action at this time.
0 commit comments