Skip to content

Instantly share code, notes, and snippets.

@ovaillancourt
Created August 10, 2012 12:54
Show Gist options
  • Save ovaillancourt/3313976 to your computer and use it in GitHub Desktop.
Save ovaillancourt/3313976 to your computer and use it in GitHub Desktop.
var purity = require('virtue-purity'); //virtue's validation
//& sanitization lib.
var user = {
name : [ purity.isString ], //Simple validation that the
//name is a string.
email : [ purity.trim, purity.isString, purity.isEmail ],
age : [ purity.isNumber, purity.greater(0), purity.toInt ],
//Array of pets
pets : [{
nickname: [purity.isString]
}],
comments : [], //Free-form field, anything can go in there.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment