matteodelabre / mongoose-beautiful-unique-validation

Plugin for Mongoose that turns duplicate errors into regular Mongoose validation errors
MIT License
117 stars 38 forks source link

Unique custom message on nested objects. #44

Closed mtnptrsn closed 6 years ago

mtnptrsn commented 7 years ago

The custom message doesn't work when using it on a nested object within a mongoose schema.

Ex:

const userSchema = new Schema({
    /*
    |----------------------
    | Structure
    |----------------------
    */
    general: {
        firstName: {
            type: String,
            required: true
        },

        lastName: {
            type: String,
            required: true
        },

        email: {
            type: String,
            required: true,
            unique: 'Mailen du angav finns redan.'
        },
   }
});

Do I need to stop using nested objects or is there another way?

matteodelabre commented 6 years ago

Hi @mtnptrsn, thanks for reporting, and sorry for taking time to answer. I believe the issue you describe is fixed in version 7.1.1. If it doesn’t, please feel free to reopen!