Git Product home page Git Product logo

jsonschemaphp's Introduction

JSON Schema PHP Validator

JSON Schema

JSON Schema is a specification for a JSON-based format for defining the structure of JSON data. JSON Schema provides a contract for what JSON data is required for a given application and how it can be modified, much like what XML Schema provides for XML. JSON Schema is intended to provide validation, documentation, and interaction control of JSON data. - http://code.google.com/p/jsonschema/

JSON Schema Validator for PHP

Json schema validator in php. It is a PHP class that validates a json data structure against a schema definition. It is a simple class that returns an object containing the result and errors that happened. - http://sourceforge.net/projects/jsonschemaphpv/

Usage Example

$schema = json_decode('{ type : "object", properties : { a : { type : "string" }} }');
$json = json_decode('{ a : 1 }');

$result = JsonSchema::validate(
    $json,
    $schema
);

if (!$result->valid) {
    echo "Errors: \n";
    print_r($result->errors);
}

jsonschemaphp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsonschemaphp's Issues

minor typo

A (very) minor typo at line 150 of JsonSchema.php causes it to crash when using the 'readonly' constraint:

if($_changing && $schema.readonly) {

Suspect this is just leftovers from the javascript version.

Project dead - pattern schema format

I have tried to follow the json schema draft as it is stated in draft 3. You can find it here http://tools.ietf.org/html/draft-zyp-json-schema-03

In the case of the "pattern" it refers to the "ECMA 262" specification. This can be found here http://www.ecma-international.org/publications/standards/Ecma-262.htm

Maybe i miss understood it but according to the ECMA-262 section "7.8.5 Regular Expression Literals" the regex contains of

/ RegularExpressionBody / RegularExpressionFlags

But when i tried to use a regex like that "/^[0-5]$/" it failes because of the "/"-es beeing added by the class itself. As i understood the "/"-es should be part of the pattern string.

To make the class better, would it be an option to check if the "/" is already there and only add them if they are missing?

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.