- Security fix: mitigate potential ReDoS attack due to non-linear regular expression.
- Fix path value appearing as
undefined
in nested schema. - Fix custom messages not taken in account in nested schema.
- Add support for Mongoose 5 (#46, #47).
- Drop support for Mongoose ≤ 4.11.3 due to #38.
- Change sub-errors’ kind from
Duplicate value
tounique
to better fit Mongoose’s conventions. - Change the default validation message to better fit Mongoose’s conventions.
- Add a plugin option to override the global default unique validation message.
- Drop support for Node.js 0.10 and 0.12.
#findOneAndUpdate
now provides failing paths info.
- Beautifies errors triggered upon a call to
Model.update()
as advertised.
- Fixed a bug where all fields of a Schema are reported as duplicated even when only some of them are (bug #29).
- Also works with
#findOneAndUpdate
(but does not provide failing paths info).
- Remove unwanted logging statement.
- Throw an error if this module is used with an outdated Mongoose version.
-
Beautifies the errors using an error middleware instead of overriding the
#save()
method. Only supports Mongoose 4.5.0 and onwards. -
Because
#save()
is not overriden anymore, thebeautifyUnique
option is now ignored. To remove the beautifying behavior, remove the plugin.
- Also works on all other ways of saving models, not only
#save()
(includingModel.create()
).
-
Beautifies any kind of Mongoose field instead of passing along the original error when working with
ObjectId
s,Buffer
s andDate
s. -
The
trySave()
method, deprecated in v3.0.0, is removed.
- Abandon parsing duplicated values using regexes and use JSON.parse for a more robust result. This allows duplicated values that contain spaces.
-
Throw a more meaningful error when the message from MongoDB cannot be parsed correctly.
-
Fix the parsing regex to allow fields containing whitespace.
- The
trySave()
method has been renamed tosave()
. This shadows the originalsave()
method provided by Mongoose, only on models that are plugged in.
-
save()
now accepts an optional hash as its first argument that mirrors Mongoose'ssave()
options. -
To disable the beautifying behavior, you can set the
beautifyUnique
option tofalse
.
- Some incompatibilities with various MongoDB versions have been fixed. Refer to #13, #14 for more information.