From fe5376ff7dc066f9aa0148a9fce184e5265fc90d Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Thu, 8 May 2014 20:16:48 +0400 Subject: [PATCH] Refactoring --- framework/validators/ExistValidator.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/framework/validators/ExistValidator.php b/framework/validators/ExistValidator.php index 69bcd94746..4a88e675e8 100644 --- a/framework/validators/ExistValidator.php +++ b/framework/validators/ExistValidator.php @@ -93,12 +93,14 @@ class ExistValidator extends Validator $query = $this->createQuery($targetClass, $params); if (is_array($object->$attribute)) { - if ($query->count() !== count($object->$attribute)) { - $this->addError($object, $attribute, $this->message); + if ($query->count() === count($object->$attribute)) { + return; } - } elseif (!$query->exists()) { - $this->addError($object, $attribute, $this->message); + } elseif ($query->exists()) { + return; } + + $this->addError($object, $attribute, $this->message); } /**