mongoose-error-beautifier
v1.0.2
Published
mongoose error beautifier converts complex mongoose errors into simple format
Downloads
9
Maintainers
Readme
mongoose-error-beautifier
Small utility to simplify mongoose errors.
Installation
$ npm install mongoose-error-beautifier
Usage
mongoose-error-beautifier
simplify the error message.
const mongooseError = require('mongoose-error-beautifier');
user.save()
.then(
() => {
console.log('saved!');
},
(err) => {
const errors = mongooseError(err);
console.log(errors);
}
);
Error Messages After
[
{
"first_name": "first_name is required."
},
{
"email": "email is required"
}
]