File tree 2 files changed +12
-1
lines changed
tests/library/Respect/Validation/Rules
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -66,10 +66,11 @@ public function check($input)
66
66
public function validate ($ input )
67
67
{
68
68
$ hasReference = $ this ->hasReference ($ input );
69
+
69
70
if ($ this ->mandatory && !$ hasReference ) {
70
71
return false ;
71
72
}
72
73
73
- return $ this ->decision ('validate ' , $ hasReference , $ input );
74
+ return $ this ->decision ('validate ' , $ hasReference , $ input ) || $ this -> getReferenceValue ( $ input ) === '' ;
74
75
}
75
76
}
Original file line number Diff line number Diff line change @@ -13,6 +13,16 @@ public function testArrayWithPresentKeyShouldReturnTrue()
13
13
$ this ->assertTrue ($ validator ->validate ($ obj ));
14
14
}
15
15
16
+ public function testArrayWithEmptyKeyShouldReturnTrue ()
17
+ {
18
+ $ validator = new Key ('someEmptyKey ' );
19
+ $ obj = array ();
20
+ $ obj ['someEmptyKey ' ] = '' ;
21
+ $ this ->assertTrue ($ validator ->assert ($ obj ));
22
+ $ this ->assertTrue ($ validator ->check ($ obj ));
23
+ $ this ->assertTrue ($ validator ->validate ($ obj ));
24
+ }
25
+
16
26
/**
17
27
* @expectedException Respect\Validation\Exceptions\KeyException
18
28
*/
You can’t perform that action at this time.
0 commit comments