Skip to content
Permalink
Browse files

Updating unique validator to ignore matches with same pk.

  • Loading branch information...
intel352 committed Mar 26, 2012
1 parent cc56bc1 commit 65f7ae77c9b4364ba22a94c322555b33b6a16222
Showing with 3 additions and 1 deletion.
  1. +3 −1 extra/EMongoUniqueValidator.php
@@ -28,7 +28,9 @@ public function validateAttribute($object, $attribute)
return;
$criteria = new EMongoCriteria;
$criteria->{$attribute} = $value;
if(!$object->getIsNewRecord())
$criteria->addCond('_id', '!=', $object->getPrimaryKey());
$criteria->addCond($attribute, '==', $value);
$count = $object->model()->count($criteria);
if($count !== 0)

0 comments on commit 65f7ae7

Please sign in to comment.
You can’t perform that action at this time.