app.use(validator()) is not a function
var router = express.Router();
const { check, validationResult } = require('express-validator');
router.post('/register',
[
check('email', 'Email is not valid').isEmail(),
check('username', 'Username field is required').not().isEmpty(),
check('password', 'Password field is required').not().isEmpty())
],
function(req, res, next) {
// Check Errors
const errors = validationResult(req);
if (errors) {
console.log(errors);
res.render('register', { errors: errors.array() });
}
else {
console.log('No Errors');
res.render('dashboard', { message: 'Successful Registration.' });
}
});
// working express validator
// use a different method to Handle errors