createValidators() public method

Unlike Model::getValidators, each time this method is called, a new list of validators will be returned.
public createValidators ( ) : ArrayObject
return ArrayObject validators
Beispiel #1
0
 /**
  * @inheritdoc
  */
 public function createValidators()
 {
     $validators = parent::createValidators();
     $rules = $this->rules;
     array_unshift($rules, ['safe']);
     foreach ($rules as $rule) {
         if ($rule instanceof Validator) {
             $validators->append($rule);
         } elseif (is_array($rule) && isset($rule[0])) {
             // attributes, validator type
             $validator = Validator::createValidator($rule[0], $this, ['value'], array_slice($rule, 1));
             $validators->append($validator);
         } else {
             throw new InvalidConfigException('Invalid validation rule: a rule must specify validator type.');
         }
     }
     return $validators;
 }