Commit 14ec7e21 by Alexander Kochetov

ExistValidator::validateValue() fixed

parent f457073d
......@@ -126,9 +126,6 @@ class ExistValidator extends Validator
*/
protected function validateValue($value)
{
if (is_array($value)) {
return [$this->message, []];
}
if ($this->targetClass === null) {
throw new InvalidConfigException('The "targetClass" property must be set.');
}
......@@ -138,8 +135,12 @@ class ExistValidator extends Validator
$query = $this->createQuery($this->targetClass, [$this->targetAttribute => $value]);
if (is_array($value)) {
return $query->count("DISTINCT [[$this->targetAttribute]]") == count($value) ? null : [$this->message, []];
} else {
return $query->exists() ? null : [$this->message, []];
}
}
/**
* Creates a query instance with the given condition.
......
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