blakehaswell/mongoose-unique-validator — pull request #5 by arosboro (2013-10-23 18:00:14+00:00)
Title: Fix for saving existing model without validation errors

This commit will resolve pull request #2.

I passed an id value of the object being validated to buildQuery(), and used that to build a query that excludes the current object being validated from results:

{ $and: [ { _id: { $ne: id } }, { field: value } ] }

All tests pass.