This code working fine. It throws errors and displayed to the webpage. But now i want to pick individual errors and display to the webpage.
// request.body validation
req.checkBody('email', 'Email is required.').notEmpty();
req.checkBody('name', 'Name is required.').notEmpty();
req.checkBody('phone', 'Phone is required.').isMobilePhone('en-IN');
req.checkBody('password1', 'Password is required.').isLength({min:6});
req.checkBody('password2', 'Password not same, try again!!').equals(password1);
var errors = req.validationErrors();
if (errors) {
console.log(req.body.params.errors);
res.render('form', {
errors: errors,
isForm: true,
register: true
});
} else {
console.log('PASSED');
}
What will be the code to console.log individual params of the errors?