req.checkBody('name', 'Name must be less than 255!!').isLength({ max: 255 })
router.post('/submit', function(req,res,next) { //check validity req.check('email', 'Invalid email address').isEmail(); req.check('password', 'Password is invalid').isLength({ min: 4}).equals(req.body.confirmPassword); var errors = req.getValidationResult(); if (errors) { req.session.errors = errors; } else { req.session.success = true; } res.redirect('/'); });
/* Handle Registration POST */ router.post('/signup', function(req, res, next) { req.checkBody('username', 'Invalid username').notEmpty().isAlphanumeric(); req.checkBody('password', 'Invalid password').notEmpty().isLength({ min: 5 }); req.getValidationResult().then(function(result) { if (!result.isEmpty()) { req.flash('message', 'Invalid input.'); return res.redirect('/signup'); } passport.authenticate('signup', { successRedirect: '/', failureRedirect: '/signup', failureFlash: true })(req, res, next); }); });
}, function (req, email, password, done) { req.checkBody('email', 'Invalid Email').notEmpty().isEmail(); req.checkBody('password', 'Invalid Password').notEmpty().isLength({min: 4}); var errors = req.validationErrors(); if (errors) {
req.checkBody('email', 'Incorrect email format.').isEmail(); req.checkBody('password', 'Password is required.').notEmpty(); req.checkBody('password', 'Password is invalid.').isLength({min:6}); req.checkBody('confirm-password', 'Password does not matched.').equals(req.body.password); req.checkBody('name', 'Name is required.').notEmpty();
app.post("/submit", (req, res) => { req.check("email", "Invalid Email").isEmail(); // isMobilePhone // isEmail() // isPostalCode // isCurrency // isCreditCard req .check("password", "Invalid Password") .isLength({ min: 6 }) .equals(req.body.confPassword); const errors = req.validationErrors(); if (errors) { req.session.errors = errors; req.session.done = false; } else { req.session.done = true; } res.redirect("/"); });