checkpoint

Validate and sanitize fields.

checkpoint

Validate and sanitize fields.

This project is still under construction and you should not expect it to be stable at the moment.

Any bugs discovered should be sent to zach(at)zachrip.net

Any requests for possible fields should be sent to zach(at)zachrip.net

There is a test suite included, although partially incomplete. If you know how to run express servers you can figure that out :)

var checkpoint = require('checkpoint');
 
/*
    {
        'key':'name of key, omitted if geo is set',
        'maxLength':'max length of key',
        'minLength':'minimum length of key'
        'max':'max number allowed',
        'min':'minimum number allowed',
        'minDate':'Date must be newer than this',
        'maxDate':'Date must be older than this',
        'geo':{
            'ip':'array of possible ip addresses',
            'countryCode':'array of possible country codes',
            'countryName':'array of possible country names',
            'regionCode':'array of possible region codes',
            'regionName':'array of possible region names',
            'city':'array of possible cities',
            'zipcode':'array of possible zipcodes',
            'latitude':'array of possible latitudes',
            'longitude':'array of possible longitudes',
            'metroCode':'array of possible metro codes',
            'areaCode':'array of possible area codes'
        },
        'method':'defaults to GET, allows POST, omitted if geo is set'
    }
*/
 
var mycheckpoint = new checkpoint([
    {
        'key':'test',
        'maxLength':15,
        'method':'GET'
    },
    {
        'key':'anotherTest',
        'max':30,
        'min':2,
        'method':'POST'
    }
]);
 
app.post('/yourpost', mycheckpoint, function (reqres) {
    var passed = req.checkpoint;
    //passed checkpoint? 
});
 
OR
 
app.use(mycheckpoint);