Paramd
JSON filtering for Node
Features:
- whitelisting params
- blacklisting params
- requiring params
- conditional application of rules
- custom error status codes
Example
var sanitized = ; sanitized ; try var json = ; catcherr return res // err.message == "username is missing" var user = json;user;
More Complex Examples
Conditional Requires:
sanitized // using ES6 syntax
Status Code on Errors
sanitized try var json = ; catche res;
Complete Documentation
You may either use a whitelisting mode (specifying attributes allowed), or a blacklisting mode (specifying attributes that aren't allowed). If you use both, an error will be thrown.
All configuration methods are chainable, and can take either a string or an array of properties.
White listing
Valid whitelisting methods are
require
optional
/allow
Whitelist Example:
var sanitized = var attrs = ;
Black listing
Blacklisting methods are
except
/filter
var sanitized = var userData = ; res;