Skip to content
Permalink
Browse files

Implemented removeRule in CakeValidationSet

  • Loading branch information...
lorenzo committed May 7, 2012
1 parent 1ff1af3 commit a7222bccd615a776c4c860eff02d5a88a70506ef
@@ -167,7 +167,7 @@ public function getRules() {
*
* @param mixed $key The key under which the rule should be set
* @param CakeRule|array $rule The validation rule to be set
* @return ModelField
* @return CakeValidationSet this instance
*/
public function setRule($key, $rule) {
if (!$rule instanceof CakeRule) {
@@ -177,6 +177,17 @@ public function setRule($key, $rule) {
return $this;
}
/**
* Removes a validation rule from the set
*
* @param mixed $key The key under which the rule should be unset
* @return CakeValidationSet this instance
*/
public function removeRule($key) {
unset($this->_rules[$key]);
return $this;
}
/**
* Sets the rules for a given field
*
@@ -291,4 +291,26 @@ public function testCount() {
$this->assertCount(2, $Set);
}
/**
* Test removeRule method
*
* @return void
*/
public function testRemoveRule() {
$Set = new CakeValidationSet('title', array(
'notEmpty' => array('rule' => 'notEmpty', 'required' => true),
'numeric' => array('rule' => 'numeric'),
'other' => array('rule' => array('other', 1)),
));
$Set->removeRule('notEmpty');
$this->assertFalse(isset($Set['notEmpty']));
$Set->removeRule('numeric');
$this->assertFalse(isset($Set['numeric']));
$Set->removeRule('other');
$this->assertFalse(isset($Set['other']));
}
}

0 comments on commit a7222bc

Please sign in to comment.
You can’t perform that action at this time.