2.0.0 • Published 9 years ago

schema-is-schema v2.0.0

Weekly downloads
248
License
ISC
Repository
github
Last release
9 years ago

schema-is-schema

returns whether or not an object is a json-schema.

supports

  • draft-04-schema
  • draft-04-schema-no-id-format

pull requests welcome!

install

with npm, do:

npm i --save schema-is-schema

generateIsSchema(options)

returns an is-my-json-valid validate function, which returns true if a schema is valid. get the last list of errors by checking validate.errors.

options

  • draft: number of json-schema draft version (default: 4)

or any options accepted by is-my-json-valid.

example

var isSchema = require('schema-is-schema')()

var personSchema = {
  id: "http://open.schema/Person#",
  properties: {
    name: {
      type: "string"
    }
  }
}

console.log(isSchema(personSchema))
// true

console.log(isSchema(null))
// false
console.loG(isSchema.errors)
// [ { field: 'data', message: 'is the wrong type' } ]

license

ISC