Esempio n. 1
0
 public function testOverrideRule()
 {
     $rule1 = $this->createMockRule();
     $rule2 = $this->createMockRule();
     $this->ruleSet->setRule('test', $rule1);
     $this->ruleSet->setRule('test', $rule2);
     $this->assertNotSame($this->ruleSet->getRule('test'), $rule1);
     $this->assertSame($this->ruleSet->getRule('test'), $rule2);
 }
Esempio n. 2
0
 public function validate(&$value)
 {
     $parsedRules = $this->parseRules();
     foreach ($parsedRules as $rule) {
         $validationRule = $this->ruleSet->getRule($rule['name']);
         if ($validationRule) {
             $validationRule->validate($value, $this->fieldName, $rule['arguments']);
         } else {
             throw new InvalidRuleException($rule['name'] . ' is not a recognized validation rule.');
         }
     }
 }