-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup, refactoring, splitted validators, tweaks
- Loading branch information
1 parent
81532ea
commit b395922
Showing
25 changed files
with
975 additions
and
450 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
this should be omitted from the composer.json totally