Complete the code to import the express-validator check function.
const { [1] } = require('express-validator');The check function is imported from express-validator to define validation rules.
Complete the code to create a validation chain for the 'email' field.
app.post('/signup', [ [1]('email').isEmail() ], (req, res) => { res.send('Done'); });
The check function creates a validation chain for the 'email' field.
Fix the error in the code to get validation results from the request.
const errors = [1](req);The validationResult function extracts validation errors from the request object.
Fill both blanks to import and use the validationResult function.
const { [1] } = require('express-validator');
const errors = [2](req);You import validationResult and then call it with the request to get errors.
Fill all three blanks to create a validation chain for 'password' with minimum length and check errors.
const { [1], [2] } = require('express-validator');
app.post('/login', [
[1]('password').isLength({ min: 6 })
], (req, res) => {
const errors = [2](req);
if (!errors.isEmpty()) {
return res.status(400).json({ errors: errors.array() });
}
res.send('Success');
});You import both check and validationResult. Use check to validate the password and validationResult to get errors.