Exemplo n.º 1
0
 /**
  * Creates validator objects based on the specification in {@link rules}.
  * This method is mainly used internally.
  *
  * @throws \Database\Exception if current class has an invalid validation rule
  * @return Validator[] validators built based on {@link rules()}.
  */
 public function createValidators()
 {
     $validators = new \Validator\Lists();
     foreach ($this->rules() as $rule) {
         if (isset($rule[0], $rule[1])) {
             $validators->add(\Validator\Validator::createValidator($rule[1], $this, $rule[0], array_slice($rule, 2)));
         } else {
             throw new \Database\Exception('{class} has an invalid validation rule. The rule must specify attributes to be validated and the validator name.', ['{class}' => get_class($this)]);
         }
     }
     return $validators;
 }