Giter Club home page Giter Club logo

jschematic's Introduction

Jschematic

Jschematic is a JSON Schema Validator for Ruby. Its aim is to validate schemas conforming to the most recent version of the JSON Schema draft standard, which today means v3.

Supporting older versions of the standard is not out of the question, but it is not a primary development focus.

Status

Core schema: fully supported Hyper schema: not supported

The format attribute supports only these formats:

  • date-time
  • date
  • ip-address
  • ipv6
  • uri

Adding ad-hoc support for different formats should be relatively painless. Look in jschematic/attributes/format.rb to get started.

Please report any bugs you find in the issue tracker here: https://github.com/msassak/jschematic/issues.

Basic Usage

require 'jschematic'
Jschematic.validate(json, schema)  # => true or false
Jschematic.validate!(json, schema) # => true or raise Jschematic::ValidationError

json and schema above must be Ruby data structures, not real JSON.

Jschematic doesn't care how you turn JSON into Ruby (though we use the fine yajl-ruby gem for testing).

Advanced Usage

Pass extra schemas to inform the validation context:

Jschematic.validate(json, schema, :context => [cs1, cs2])

Each context schema will be consulted in those cases where cross-schema referencing is allowed, e.g. $ref.

To enable debugging support, set :debug to true in the options hash:

Jschematic.validate!(json, schema, :debug => true)

With debugging on a warning is printed when schema contain unknown attributes.

Testing

$ cucumber
$ rspec spec

Or rake if you want to run both.

Links

Copyright

Copyright (c) 2011 Mike Sassak. See LICENSE for details.

jschematic's People

Contributors

jarib avatar msassak avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.