Skip to content

Commit

Permalink
cleanup, refactoring, splitted validators, tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalkaoz committed Jan 2, 2012
1 parent 81532ea commit b395922
Show file tree
Hide file tree
Showing 25 changed files with 975 additions and 450 deletions.
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",

This comment has been minimized.

Copy link
@GrahamCampbell

GrahamCampbell May 4, 2015

Contributor

this should be omitted from the composer.json totally

This comment has been minimized.

Copy link
@GrahamCampbell

GrahamCampbell May 4, 2015

Contributor

Oh, it is now. :)

"authors": [
{
"name": "Bruno Prieto Reis",
Expand All @@ -14,6 +14,14 @@
{
"name": "Justin Rainbow",
"email": "justin.rainbow@gmail.com"
},
{
"name": "Igor Wiedler",
"email": "igor@wiedler.ch"
},
{
"name": "Robert Schönthal",
"email": "seroscho@googlemail.com"
}
],
"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

0 comments on commit b395922

Please sign in to comment.