X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=node_modules%2Fis-my-json-valid%2Fexample.js;fp=node_modules%2Fis-my-json-valid%2Fexample.js;h=f70f4dfb5ca5fc0fe208b48288ed5dd7e3ddee06;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/node_modules/is-my-json-valid/example.js b/node_modules/is-my-json-valid/example.js new file mode 100644 index 000000000..f70f4dfb5 --- /dev/null +++ b/node_modules/is-my-json-valid/example.js @@ -0,0 +1,18 @@ +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)