mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #11809 from WrDX/WrDX-removing-non-existing-rule
Don't break on removing a non-existing rule
This commit is contained in:
commit
68de980972
2 changed files with 4 additions and 1 deletions
|
@ -594,7 +594,7 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable {
|
|||
$this->_parseRules();
|
||||
if ($rule === null) {
|
||||
unset($this->_fields[$field]);
|
||||
} else {
|
||||
} elseif (array_key_exists($field, $this->_fields)) {
|
||||
$this->_fields[$field]->removeRule($rule);
|
||||
}
|
||||
return $this;
|
||||
|
|
|
@ -2007,6 +2007,9 @@ class ModelValidationTest extends BaseModelTest {
|
|||
$this->assertTrue(isset($Validator['other']));
|
||||
$this->assertFalse(isset($Validator['other']['numeric']));
|
||||
$this->assertTrue(isset($Validator['other']['between']));
|
||||
|
||||
$Validator->remove('other');
|
||||
$Validator->remove('other', 'between');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue