Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
# JSON Schema for PHP [![Build status...](https://secure.travis-ci.org/justinrainbow/json-schema.png)](http://travis-ci.org/justinrainbow/json-schema)
# JSON Schema for PHP [![Build Status](https://secure.travis-ci.org/digitalkaoz/json-schema.png)](http://travis-ci.org/digitalkaoz/json-schema)

Documentation can be found at http://jsonschema.readthedocs.org/
A PHP Implementation for validating `JSON` Structures against a given `Schema`.

See [json-schema](http://json-schema.org/) for more details.

## Installation

### Library

$ git clone https://github.com/justinrainbow/json-schema.git

### Dependencies

#### via `submodules` (*will use the Symfony ClassLoader Component*)

$ git submodule update --init

#### via [`composer`](https://github.com/composer/composer) (*will use the Composer ClassLoader*)

$ wget http://getcomposer.org/composer.phar
$ php composer.phar install

## Usage

```php
<?php

$validator = new JsonSchema\Validator();
$result = $validator->validate(json_decode($json), json_decode($schema));
$validator->check(json_decode($json), json_decode($schema));

if ($result->valid) {
if ($validator->isValid()) {
echo "The supplied JSON validates against the schema.\n";
} else {
echo "JSON does not validate. Violations:\n";
foreach ($result->errors as $error) {
echo "[{$error['property']}] {$error['message']}\n";
foreach ($validator->getErrors() as $error) {
echo sprintf("[%s] %s\n",$error['property'], $error['message']);
}
}
```

## Running the tests

$ git submodule update --init
$ phpunit
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"homepage": "https://github.com/justinrainbow/json-schema",
"type": "library",
"license": "NewBSD",
"version": "1.0.0",
"version": "1.1.0",
"authors": [
{
"name": "Bruno Prieto Reis",
Expand All @@ -14,6 +14,14 @@
{
"name": "Justin Rainbow",
"email": "[email protected]"
},
{
"name": "Igor Wiedler",
"email": "[email protected]"
},
{
"name": "Robert Schönthal",
"email": "[email protected]"
}
],
"require": {
Expand Down
16 changes: 11 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@
bootstrap="tests/bootstrap.php"
verbose="true"
>
<testsuites>
<testsuite name="JSON Schema Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<testsuites>
<testsuite name="JSON Schema Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./src/JsonSchema/</directory>
</whitelist>
</filter>
</phpunit>
16 changes: 0 additions & 16 deletions src/JsonSchema/Undefined.php

This file was deleted.

Loading