Skip to content

Commit 378e114

Browse files
committed
Merge branch '0.7' into 0.8
2 parents 2914eba + 11be936 commit 378e114

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

library/Rules/AbstractRelated.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ public function check($input)
6666
public function validate($input)
6767
{
6868
$hasReference = $this->hasReference($input);
69+
6970
if ($this->mandatory && !$hasReference) {
7071
return false;
7172
}
7273

73-
return $this->decision('validate', $hasReference, $input);
74+
return $this->decision('validate', $hasReference, $input) || $this->getReferenceValue($input) === '';
7475
}
7576
}

tests/Rules/KeyTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ public function testArrayWithPresentKeyShouldReturnTrue()
1313
$this->assertTrue($validator->validate($obj));
1414
}
1515

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+
1626
/**
1727
* @expectedException Respect\Validation\Exceptions\KeyException
1828
*/

0 commit comments

Comments
 (0)