A sanitizer for (nested) objects with a simple API. For validating objects, check out valee.
$ npm install sanee
var sanee = require('sanee');
// create sanitize-function
var sanitize = sanee({
user: {
email: sanee.normalizeEmail({ lowercase: true }),
name: sanee.trim()
}
});
// sanitize input
var sanitizedInput = sanitize({
user: {
email: 'Maximilian.schmitt@googleMail.com',
name: ' Max '
}
});
// print sanitized input
console.log(sanitizedInput);
Output:
{
user: {
email: 'maximilianschmitt@gmail.com',
name: 'Max'
}
}
All sanitizers of sanee currently map to the sanitizers of validator.js.