1.0.2 • Published 6 years ago

mongoose-error-beautifier v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

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"
        }
    ]