Input sanitizing library for node.js
This library is for the purpose of sanitizing user input. The examples below show some of the built in sanitizers. You can create your own custom sanitizers. Please refer to the tests for more examples of how to use this library.
npm install --save sanitize
npm test
var express = require('express');
var app = express();
app.use(require('sanitize').middleware);
app.get('/ping', function(req, res) {
var param = req.queryInt('param');
res.send('pong ' + (typeof param) + ' ' + param);
});
app.listen(8080);
This will remove all keys from a plain object that are not String
, Integer
, or Boolean
. It's great for sanitizing objects before inserting into the database.