Home

Awesome

json-schema-suite

JSON Schema components bundled for easy use.

Installation

component:

$ component install ericgj/json-schema-suite

npm:

$ npm install json-schema-suite

browser standalone:

Include build.js or build.min.js in a script tag. This will give you a window.jsonSchema global. If you would prefer a different global, clone this repo and rebuild like:

$ component install
$ component build --standalone myGlobal

Then move the build/build.js file into your project.

Examples


var suite = require('json-schema-suite')

// Simple validation
// see json-schema-valid for more details

var validator = new suite.Validator()

validator.validateRaw(schema,instance); // boolean
validator.error();   // validation error(s) wrapped in error object


// HTTP correlation

var agent = new suite.Agent()

agent.get('/api', function(err,correlation){

  // validation
  correlation.once('error', function(e){
    console.error(e);
  })

  if (correlation.validate()) {
    //...
  }

  
  // follow resolved links in correlations
  agent.follow( correlation.rel('instances'), function(){
    //...
  });

})

API

See json-schema-agent, json-schema-valid, json-schema-core for details.

Running tests

In browser

$ node test/server.js

And browse http://localhost:3000.

In node

$ node test/server.js &
$ npm test

License

MIT