req.checkBody('email', 'Invalid email!!').isEmail()
req.checkBody('email', 'Invalid email!!').isEmail() req.checkBody('password', 'Password field is empty').notEmpty()
req.checkBody('email', 'Email is invalid').isEmail()
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('/'); });
passport.use('local.signin', new LocalStartergy({ usernameField: 'email', passwordField: 'password', passReqToCallback: true }, function (req, email, password, done) { req.checkBody('email', 'Invalid Email').notEmpty().isEmail(); req.checkBody('password', 'Invalid Password').notEmpty(); var errors = req.validationErrors(); if (errors) { var messages = []; errors.forEach(function (error) { messages.push(error.msg) }); return done(null, false, req.flash('error', messages)); } User.findOne({'email': email}, function (err, user) { if (err) { return done(err); } else { if (!user) { return done(null, false, {message: 'No user found!'}); } if (!user.validPassword(password)) { return done(null, false, {message: 'Wrong Password!'}); } return done(null, user); } }) }));
}, (req, email, password, callback) => { req.checkBody('email', 'Email is required.').notEmpty(); req.checkBody('email', 'Invalid email format').isEmail(); req.checkBody('password', 'Password is required.').notEmpty(); let errors = req.validationErrors();
req.checkBody('email', 'Email is not valid').isEmail(); req.checkBody('username', 'Username is required').notEmpty(); req.checkBody('password', 'Password is required').notEmpty();
router.post('/products', (req, res, next) => { req.checkBody('title', 'Enter a valid email address').isEmail(); var errors = req.validationErrors(); if(errors){ res.send(errors); } else{ var p = new Product(); p.title = req.body.title; p.price = req.body.price; p.instock = req.body.instock; p.photo = req.body.photo; p.save((err, data) => { if(err) { res.json({ data: {}, mes: `Error . ${err}` }); } else{ res.json({ data: data, mes: 'Successfuly' }); } }); } });
req.checkBody('email', 'Email is invalid').isEmail()
req.checkBody('password', 'Password is required').notEmpty(); req.checkBody('name', 'Name is required').notEmpty(); req.checkBody('email', 'Email is required and must be in a valid form').notEmpty().isEmail();
passReqToCallback: true }, 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();
return next(err) req.checkBody('email', 'Email is not valid').isEmail(); req.checkBody('password', 'Passwords have to match').equals(req.body.verifyPassword); let invalidFieldErrors = req.validationErrors()
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("/"); });
req.checkBody('password', 'Password is required').notEmpty(); req.checkBody('name', 'Name is required').notEmpty(); req.checkBody('email', 'Email is required and must be in a valid form').notEmpty().isEmail();
}, function(req, email, password, done){ req.checkBody('email', 'Invalid email').notEmpty().isEmail(); req.checkBody('password', 'Invalid password').notEmpty(); var errors = req.validationErrors();