Skip to content

holodex/schema-is-schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors