mirror of
https://github.com/nodejs/node.git
synced 2025-05-18 17:26:24 +00:00

PR-URL: https://github.com/nodejs/io.js/pull/2072 Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com> Reviewed-by: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Alex Kocharin <alex@kocharin.ru>
19 lines
430 B
JavaScript
19 lines
430 B
JavaScript
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)
|