mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
430 B
19 lines
430 B
10 years ago
|
var validator = require('./')
|
||
|
|
||
|
var validate = validator({
|
||
|
type: 'object',
|
||
|
properties: {
|
||
|
hello: {
|
||
|
required: true,
|
||
|
type: 'string'
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
|
||
|
console.log('should be valid', validate({hello: 'world'}))
|
||
|
console.log('should not be valid', validate({}))
|
||
|
|
||
|
// get the last error message by checking validate.error
|
||
|
// the following will print "data.hello is required"
|
||
|
console.log('the errors were:', validate.errors)
|