Skip to content

Instantly share code, notes, and snippets.

View foxbunny's full-sized avatar

Hajime Yamasaki Vukelic foxbunny

View GitHub Profile
@foxbunny
foxbunny / gist:1082433
Created July 14, 2011 13:22
Bind node-validator to req
/*
* This binds the node-validator library to the req object so that
* the validation / sanitization methods can be called on parameter
* names rather than the actual strings.
*
* 1. Be sure to include `req.mixinParams()` as middleware to merge
* query string, body and named parameters into `req.params`
*
* 2. To validate parameters, use `req.check(param_name, [err_message])`
* e.g. req.check('param1').len(1, 6).isInt();