Hi I'm trying to get a mongoose error message, and the description has an array index in its name. This is in a unit test.
{message: 'Validation failed',
name: 'ValidationError',
errors:
{ 'contactInfo.0.email':
{ message: 'Invalid email',
name: 'ValidatorError',
path: 'email',
type: 'user defined',
value: 'fjksdal' } },
key: 'undefined.0.undefined' }
previous example to get message i would do this:
(err.errors.passHash.message).should.eql('PASSWORD_NOT_HASHED');
However variations of this fail and I can see why, not sure what the workaround is.
(err.errors.contactInfo.0.email.message).should.eql('Invalid Email')
thanks