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

Incorrect regex for compound keys #48

Open men232 opened 6 years ago

men232 commented 6 years ago

Hey, have a issues with this error message parsing E11000 duplicate key error index: heroku_4k0w7dhh.users.$email_1 dup key:.

Current regex parse this as: heroku_4k0w7dhh.users.$email_1. Actually these are my collection indexes:

{ name_1: [ [ 'name', 1 ] ],
  email_1: [ [ 'email', 1 ] ],
  _id_: [ [ '_id', 1 ] ],
  phone_1: [ [ 'phone', 1 ] ] } 

As a result, I do not get a beautiful error.

sato-sh commented 6 years ago

I too am experiencing this same issue and the PR seems to fix this