I want to check if a string is an email. This is the code.
req.checkBody('email', 'Invalid email address').isEmail();
var validationErrors = req.validationErrors();
if(validationErrors) {
console.log(`Validation errors ${validationErrors}`);
}
console output:
Validation errors [object Object]
You are using Template Literals feature of ES6. It can embed variables in string like you did. But it doesn't parse object
and array
. Use traditional console.log
:
console.log('Validation errors ', validationErrors);
PS: Use console.error
to log errors, instead of console.log
.