Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 11th, 2012  |  syntax: None  |  size: 0.51 KB  |  views: 60  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     req.onValidationError(function (msg) {
  2.       // put the validation msg if it doesn't exist
  3.       if (_.indexOf(errors, msg) === -1) { errors.push(msg); }
  4.       return this;
  5.     });
  6.     // Validate user input
  7.     try {
  8.       req.check('name', 'Please enter a valid name').len(3,30);
  9.       req.check('comment', 'Please enter a valid comment').len(3,50);
  10.     }
  11.     catch (err) { }
  12.     if (errors.length) {
  13.       req.session.errors = errors;
  14.       res.redirect('/');
  15.     } else {
  16.       render your page
  17.     }