private function createEmbeddedValidator($model)
{
$rule = $this->rule;
if ($rule instanceof Validator) {
return $rule;
} elseif (is_array($rule) && isset($rule[0])) {
// validator type
if (!is_object($model)) {
$model = new Model();
// mock up context model
}
return Validator::createValidator($rule[0], $model, $this->attributes, array_slice($rule, 1));
} else {
throw new InvalidConfigException('Invalid validation rule: a rule must be an array specifying validator type.');
}
}