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:
Mark Sch 2018-03-14 17:01:46 +01:00 committed by GitHub
commit 68de980972
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -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;

View file

@ -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');
}
/**