File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
All notable changes to ` laravel-validator-phone ` will be documented in this file.
4
4
5
+ ### 1.1.1
6
+ - Empty values are now valid phone numbers (You should be using the 'required' validation rule when checking for non empty values)
7
+
5
8
### 1.1.0
6
9
- Added a custom validation message
7
10
Original file line number Diff line number Diff line change 4
4
5
5
class Validator
6
6
{
7
- public function isPhone ($ value )
7
+ public function __call ($ a , $ b )
8
+ {
9
+ return empty ($ b [0 ]) || $ this ->{$ a }($ b [0 ]);
10
+ }
11
+
12
+ protected function isPhone ($ value )
8
13
{
9
14
return $ this ->isE164 ($ value );
10
15
}
11
16
12
- public function isE164 ($ value )
17
+ protected function isE164 ($ value )
13
18
{
14
19
$ conditions = [];
15
20
$ conditions [] = strpos ($ value , "+ " ) === 0 ;
Original file line number Diff line number Diff line change @@ -23,6 +23,14 @@ public function testValidatorPhone()
23
23
$ this ->assertEquals (true , $ this ->validate ('+15556667777 ' , 'phone ' ));
24
24
}
25
25
26
+ public function testValidatorWithEmpty ()
27
+ {
28
+ $ this ->assertEquals (true , $ this ->validate ('' , 'phone ' ));
29
+ $ this ->assertEquals (true , $ this ->validate (null , 'phone ' ));
30
+ $ this ->assertEquals (true , $ this ->validate ([], 'phone ' ));
31
+ $ this ->assertEquals (true , $ this ->validate (false , 'phone ' ));
32
+ }
33
+
26
34
public function testValidatorPhoneE164 ()
27
35
{
28
36
$ this ->assertEquals (true , $ this ->validate ('+15556660000 ' , 'phone:E164 ' ));
You can’t perform that action at this time.
0 commit comments