Welcome to mirror list, hosted at ThFree Co, Russian Federation.

example.js « is-my-json-valid « node_modules - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f70f4dfb5ca5fc0fe208b48288ed5dd7e3ddee06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)