Created
September 19, 2012 19:30
-
-
Save ovaillancourt/3751706 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var validation = require( './validation' ); | |
var v = require('./validators' ); | |
function lowerCase( value, err ){ | |
return value.toLowerCase(); | |
} | |
var userSchema = { | |
firstname : [ v.trim() ], | |
lastname : [ v.trim() ], | |
personal : { | |
email : [ v.trim(), v.isEmail(), lowerCase ], | |
age : [ v.toInt(), v.min(0) ] | |
} | |
}; | |
var fakeUser = { | |
firstname : 'Olivier', | |
lastname: 'Vaillancourt', | |
personal: { | |
email: '[email protected] ', | |
age: 5.5 | |
} | |
}; | |
validation.validate( fakeUser, userSchema ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment