D:\nodejs_mongodb_project>npm install --save express-validator
Add the following code in the controller
const { check, validationResult } = require('express-validation')
exports.admin_regi_add = function (req, res) {
check('fullname').isLength({ min: 3 }),
check('fullname').isLength({ min: 3 }),
check('mobile').isLength({ min: 3 }),
check('pword').isLength({ min: 3 }),
check('cpword').isLength({ min: 3 }),
check('birth').isLength({ min: 3 }),
check('sex').isLength({ min: 3 }),
check('prefer_con').isLength({ min: 3 }),
check('profile_pic').isLength({ min: 3 }),
check('email').isEmail()
const errors = validationResult(req)
if (!errors.isEmpty()) {
return res.status(422).json({ errors: errors.array() })
}
};
These are validation type
Total : 35219
Today :12
Today Visit Country :