Skip to content

Commit

Permalink
Merge pull request #11809 from WrDX/WrDX-removing-non-existing-rule
Browse files Browse the repository at this point in the history
Don't break on removing a non-existing rule
  • Loading branch information
dereuromark committed Mar 14, 2018
2 parents 5d7f3a6 + b225443 commit 68de980
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Model/ModelValidator.php
Expand Up @@ -594,7 +594,7 @@ public function remove($field, $rule = null) {
$this->_parseRules();
if ($rule === null) {
unset($this->_fields[$field]);
} else {
} elseif (array_key_exists($field, $this->_fields)) {
$this->_fields[$field]->removeRule($rule);
}
return $this;
Expand Down
3 changes: 3 additions & 0 deletions lib/Cake/Test/Case/Model/ModelValidationTest.php
Expand Up @@ -2007,6 +2007,9 @@ public function testRemoveRule() {
$this->assertTrue(isset($Validator['other']));
$this->assertFalse(isset($Validator['other']['numeric']));
$this->assertTrue(isset($Validator['other']['between']));

$Validator->remove('other');
$Validator->remove('other', 'between');
}

/**
Expand Down

0 comments on commit 68de980

Please sign in to comment.