"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/is-my-json-valid/example.js" (7 Feb 2017, 430 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 var validator = require('./')
    2 
    3 var validate = validator({
    4   type: 'object',
    5   properties: {
    6     hello: {
    7       required: true,
    8       type: 'string'
    9     }
   10   }
   11 })
   12 
   13 console.log('should be valid', validate({hello: 'world'}))
   14 console.log('should not be valid', validate({}))
   15 
   16 // get the last error message by checking validate.error
   17 // the following will print "data.hello is required"
   18 console.log('the errors were:', validate.errors)