dscape / val

simple validation middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is apache 2.0. Fork it. If you do a good job at it I will use your thing instead of mine.

INSERT MEME

build status

How it works if you have something in production or something:

module.exports = function routes(app) {
  app.get('/', function (req, res) {
    res.render('index');
  });

  app.post('/create-an-account', [require('./validate/account')], function (req, res) {
    res.render('account_created');
  });

};

Validation code looks something like this:

var val = require('val')();

module.exports = val.validate([{
  required: 'email'
  }, {
  required: 'password'
  }], function on_error(err, req, res, next) {
  res.render('account_created', {
    flash: err.message
  });
});

TOTAL WATEVS

About

simple validation middleware