File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ class Country
4242
4343 public const CHAD = 'TD ' ;
4444
45+ public const CHINA = 'zh ' ;
46+
4547 public const COMOROS = 'KM ' ;
4648
4749 public const CONGO = 'CG ' ;
Original file line number Diff line number Diff line change @@ -177,6 +177,16 @@ protected function validateTR()
177177 return preg_match ('/^(?:\+90|0)(?:\s?[1-9]\d{2}\s?\d{3}\s?\d{2}\s?\d{2}|[1-9]\d{2}-?\d{3}-?\d{2}-?\d{2})$/ ' , $ this ->value );
178178 }
179179
180+ /**
181+ * Validate Chinese phone number.
182+ *
183+ * @return false|int
184+ */
185+ protected function validateZH ()
186+ {
187+ return preg_match ('/^(?:\+86)?1[3-9]\d{9}$/ ' , $ this ->value );
188+ }
189+
180190 /**
181191 * Call the phone validator method for each country code and return the results.
182192 *
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ public function all_phone_number_is_valid_by_specific_code()
8484 'phone_ru ' => [new ValidPhoneNumber (Country::RUSSIA )],
8585 'phone_se ' => [new ValidPhoneNumber (Country::SWEDEN )],
8686 'phone_tr ' => [new ValidPhoneNumber (Country::TURKEY )],
87+ 'phone_ch ' => [new ValidPhoneNumber (Country::CHINA )],
8788 ];
8889 $ data = [
8990 'phone_ir ' => '09125555555 ' ,
@@ -102,6 +103,7 @@ public function all_phone_number_is_valid_by_specific_code()
102103 'phone_ru ' => '+79101234567 ' ,
103104 'phone_se ' => '+46701234567 ' ,
104105 'phone_tr ' => '+905551234567 ' ,
106+ 'phone_ch ' => '+8613812345678 ' ,
105107 ];
106108 $ passes = $ this ->app ['validator ' ]->make ($ data , $ rules )->passes ();
107109
You can’t perform that action at this time.
0 commit comments