Expressjs data validation middleware.
var bodyParser = require('body-parser')
, check = require('express-check')
, rule = check.rule
;
var app = express();
// always use bodyParser before check middleware
app.use(bodyParser());
app.get(
'/login',
check('body',
rule('username').notEmpty(),
rule('password').isLength(6, 18)
)
);
dataSource
could be either body
, query
or params
.
Following a list of rule
created by check.rule()
field
is the field name that being validate.
MIT