Code Monkey home page Code Monkey logo

php-json-schema's Introduction

This library provides JSON schema validation using the schema found at http://json-schema.org. Note that it is not yet feature complete, but does support basic validation. The JSON schema draft can be found at http://tools.ietf.org/html/draft-zyp-json-schema-03

Requirements

  • PHP 5.3 or greater (requires namespace and closure support)

Usage

$someJson = '{"foo":"bar"}';
$jsonObject = json_decode($someJson);

$validator = new JsonValidator('/path/to/yourschema.json');

$validator->validate($jsonObject);

Supported Types

Types may be defined as either a single string type name, or an array of allowable type names.

  • string
  • number
  • integer
  • boolean
  • object
  • array
  • null
  • any

Supported Definitions

Not all definitions are yet supported, but here is a list of those which are:

  • properties (object)
  • additionalProperties (object)
  • required (all)
  • pattern (string)
  • minLength (string)
  • maxLength (string)
  • format (string, number, integer)
  • minimum (number, integer)
  • maximum (number, integer)
  • exclusiveMinimum (number, integer)
  • exclusiveMaximum (number, integer)
  • divisibleBy (number, integer)
  • enum (array)
  • minItems (array)
  • maxItems (array)
  • uniqueItems (array)
  • items (array)
  • disallow (all)

The following definitions are not yet supported:

  • patternProperties
  • dependencies
  • extends
  • id
  • $ref
  • $schema

php-json-schema's People

Contributors

hasbridge avatar mtdowling avatar

Stargazers

Aleksei Tcelishchev avatar

Watchers

James Cloos avatar Aleksei Tcelishchev 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.