typeerror 3a expressvalidator is not a function

Solutions on MaxInterview for typeerror 3a expressvalidator is not a function by the best coders in the world

showing results for - "typeerror 3a expressvalidator is not a function"
Alejandro
11 Aug 2016
1While using version 6, you will encounter the following error:
2
3TypeError: expressValidator is not a function
4
5To avoid this issue you can use the previous version which is 5.3.1
Diego
11 Jan 2021
1var router = express.Router();
2const { check, validationResult } = require('express-validator');
3
4router.post('/register',
5  [
6    check('email', 'Email is not valid').isEmail(),
7    check('username', 'Username field is required').not().isEmpty(),
8    check('password', 'Password field is required').not().isEmpty())
9  ], 
10  function(req, res, next) {
11
12  // Check Errors
13  const errors = validationResult(req);
14  if (errors) {
15    console.log(errors);
16    res.render('register', { errors: errors.array() });
17  }
18  else {
19    console.log('No Errors');
20    res.render('dashboard', { message: 'Successful Registration.' });
21  }
22});
23// working express validator
24// use a different method to Handle errors
Tomas
18 Jan 2018
1console.log(`error: ${err}`);
2res.status(code).json({
3    error: err
4});
5// good error handling by express validation Pg 2
6// make utils/app.js and write this code inside it