Mongoose Validators Mongoose Validators mongoose mongoose

Mongoose Validators


According to Mongoose Validation docs, you can run validators when updating you data, but you must explicitly tell Mongoose to run them.

This is a quote from the Update Validators section taken from the link above:

Mongoose also supports validation for update() and findOneAndUpdate() operations. In Mongoose 4.x, update validators are off by default - you need to specify the runValidators option.

To turn on update validators, set the runValidators option for update() or findOneAndUpdate(). Be careful: update validators are off by default because they have several caveats.