leepowelldev / mongoose-validator

Validators for mongoose models utilising validator.js
MIT License
379 stars 43 forks source link

change context for extended validators #34

Closed AlexeyKhristov closed 8 years ago

AlexeyKhristov commented 8 years ago

there is no way to get access to model instance inside extended validator. opposite to mongoose validation

http://mongoosejs.com/docs/validation.html, 'Update Validators and this' section

this refers to the document being validated when using document validation. However, when running update validators, the document being updated may not be in the server's memory, so by default the value of this is not defined.

PS: all tests passed

leepowelldev commented 8 years ago

👍 Would you mind adding a test or two to confirm that the model instance is retained?

AlexeyKhristov commented 8 years ago

test added

leepowelldev commented 8 years ago

Thanks 👍