Skip to content

Commit

Permalink
Fix Validator::equals() never passing.
Browse files Browse the repository at this point in the history
This method would always trigger validation errors as the conditions
were incorrectly defined.

Refs #9238
  • Loading branch information
markstory committed Aug 9, 2016
1 parent 3d3e354 commit 26e6bf0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Validation/Validator.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ public function equals($field, $value, $message = null, $when = null)
$extra = array_filter(['on' => $when, 'message' => $message]); $extra = array_filter(['on' => $when, 'message' => $message]);


return $this->add($field, 'equals', $extra + [ return $this->add($field, 'equals', $extra + [
'rule' => ['comparison', '=', $value] 'rule' => ['comparison', '==', $value]
]); ]);
} }


Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Validation/ValidatorTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1190,7 +1190,8 @@ public function testLessThanOrEqual()
public function testEquals() public function testEquals()
{ {
$validator = new Validator(); $validator = new Validator();
$this->assertProxyMethod($validator, 'equals', 5, ['=', 5], 'comparison'); $this->assertProxyMethod($validator, 'equals', 5, ['==', 5], 'comparison');
$this->assertEmpty($validator->errors(['username' => 5]));
$this->assertNotEmpty($validator->errors(['username' => 6])); $this->assertNotEmpty($validator->errors(['username' => 6]));
} }


Expand Down

0 comments on commit 26e6bf0

Please sign in to comment.