Skip to content

Commit

Permalink
Merge pull request #274 from Kison/master
Browse files Browse the repository at this point in the history
EMongoExistValidator not uses criteria parameter
  • Loading branch information
Sammaye authored Dec 10, 2016
2 parents 3c57ad3 + b0f95bd commit 408f2f2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions validators/EMongoExistValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ protected function validateAttribute($object, $attribute)
$attributeName = $this->attributeName === null ? $attribute : $this->attributeName;
$finder = EMongoDocument::model($className);

$criteria = array($attributeName => $this->mongoId ? new MongoId($value) : $value);
$criteria = $this->criteria;
$criteria[$attributeName] = $this->mongoId ? new MongoId($value) : $value;

if(!$finder->exists($criteria)){
$message = $this->message !== null ? $this->message : Yii::t('yii', '{attribute} "{value}" is invalid.');
$this->addError($object, $attribute, $message, array('{value}' => CHtml::encode($value)));
}
}
}
}

0 comments on commit 408f2f2

Please sign in to comment.