public function isUnique($value, $field, Model $obj, $process = null) { $query = $obj->query(false)->in($field, $value); if ($obj->isExists()) { $query->notIn($obj->getReferenceData()); } return $query->count() > 0 ? false : true; }