Skip to content

Commit

Permalink
ahora el mensaje específico tiene el nombre uniqueMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Carlos Muñoz committed Jan 7, 2024
1 parent cbe0fa3 commit f97fb16
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ module.exports = function (schema, options) {

if (indexOptions.unique) {
const paths = Object.keys(index[0]);
//FIX cambiar este each por un forEach
each(paths, pathName => {
// Choose error message
const pathMessage = typeof indexOptions.unique === "string" ? indexOptions.unique : message;
const pathMessage = typeof indexOptions.uniqueMessage === "string" ? indexOptions.uniqueMessage : message;

// Obtain the correct path object
const path = deepPath(schema, pathName) || schema.path(pathName);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mongoose-unique-validator",
"version": "2.1.7",
"version": "3.0.0",
"description": "mongoose-unique-validator is a plugin which adds pre-save validation for unique fields within a Mongoose schema.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit f97fb16

Please sign in to comment.