Commit 3ff8f10d by slavcodev

Add array conversion on creating validator

parent 9bf7f791
...@@ -390,7 +390,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess ...@@ -390,7 +390,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
if ($rule instanceof Validator) { if ($rule instanceof Validator) {
$validators->append($rule); $validators->append($rule);
} elseif (is_array($rule) && isset($rule[0], $rule[1])) { // attributes, validator type } elseif (is_array($rule) && isset($rule[0], $rule[1])) { // attributes, validator type
$validator = Validator::createValidator($rule[1], $this, $rule[0], array_slice($rule, 2)); $validator = Validator::createValidator($rule[1], $this, (array) $rule[0], array_slice($rule, 2));
$validators->append($validator); $validators->append($validator);
} else { } else {
throw new InvalidConfigException('Invalid validation rule: a rule must specify both attribute names and validator type.'); throw new InvalidConfigException('Invalid validation rule: a rule must specify both attribute names and validator type.');
......
...@@ -29,7 +29,7 @@ class FakedValidationModel extends Model ...@@ -29,7 +29,7 @@ class FakedValidationModel extends Model
{ {
return [ return [
[['val_attr_a', 'val_attr_b'], 'required', 'on' => 'reqTest'], [['val_attr_a', 'val_attr_b'], 'required', 'on' => 'reqTest'],
[['val_attr_c'], 'integer'], ['val_attr_c', 'integer'],
]; ];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment