framework/validators/ExistValidator.php
private function queryValueExists($query, $value)
    {
        if (is_array($value)) {
            return $query->count("DISTINCT [[$this->targetAttribute]]") == count($value) ;
        }
        return $query->exists();
    }
private function queryValueExists($query, $value)
    {
        if (is_array($value)) {
            return $query->count("DISTINCT [[$this->targetAttribute]]") == count($value) ;
        }
        return $query->exists();
    }
Run query to check if value exists

@param QueryInterface $query
@param mixed $value the value to be checked
@return bool