Skip to content

Commit b395922

Browse files
committed
cleanup, refactoring, splitted validators, tweaks
1 parent 81532ea commit b395922

25 files changed

+975
-450
lines changed

README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
1-
# JSON Schema for PHP [![Build status...](https://secure.travis-ci.org/justinrainbow/json-schema.png)](http://travis-ci.org/justinrainbow/json-schema)
1+
# JSON Schema for PHP [![Build Status](https://secure.travis-ci.org/digitalkaoz/json-schema.png)](http://travis-ci.org/digitalkaoz/json-schema)
22

3-
Documentation can be found at http://jsonschema.readthedocs.org/
3+
A PHP Implementation for validating `JSON` Structures against a given `Schema`.
4+
5+
See [json-schema](http://json-schema.org/) for more details.
6+
7+
## Installation
8+
9+
### Library
10+
11+
$ git clone https://github.com/justinrainbow/json-schema.git
12+
13+
### Dependencies
14+
15+
#### via `submodules` (*will use the Symfony ClassLoader Component*)
16+
17+
$ git submodule update --init
18+
19+
#### via [`composer`](https://github.com/composer/composer) (*will use the Composer ClassLoader*)
20+
21+
$ wget http://getcomposer.org/composer.phar
22+
$ php composer.phar install
423

524
## Usage
625

726
```php
827
<?php
928

1029
$validator = new JsonSchema\Validator();
11-
$result = $validator->validate(json_decode($json), json_decode($schema));
30+
$validator->check(json_decode($json), json_decode($schema));
1231

13-
if ($result->valid) {
32+
if ($validator->isValid()) {
1433
echo "The supplied JSON validates against the schema.\n";
1534
} else {
1635
echo "JSON does not validate. Violations:\n";
17-
foreach ($result->errors as $error) {
18-
echo "[{$error['property']}] {$error['message']}\n";
36+
foreach ($validator->getErrors() as $error) {
37+
echo sprintf("[%s] %s\n",$error['property'], $error['message']);
1938
}
2039
}
2140
```
2241

2342
## Running the tests
2443

25-
$ git submodule update --init
2644
$ phpunit

composer.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"homepage": "https://github.com/justinrainbow/json-schema",
66
"type": "library",
77
"license": "NewBSD",
8-
"version": "1.0.0",
8+
"version": "1.1.0",
99
"authors": [
1010
{
1111
"name": "Bruno Prieto Reis",
@@ -14,6 +14,14 @@
1414
{
1515
"name": "Justin Rainbow",
1616
"email": "justin.rainbow@gmail.com"
17+
},
18+
{
19+
"name": "Igor Wiedler",
20+
"email": "igor@wiedler.ch"
21+
},
22+
{
23+
"name": "Robert Schönthal",
24+
"email": "seroscho@googlemail.com"
1725
}
1826
],
1927
"require": {

phpunit.xml.dist

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212
bootstrap="tests/bootstrap.php"
1313
verbose="true"
1414
>
15-
<testsuites>
16-
<testsuite name="JSON Schema Test Suite">
17-
<directory>tests</directory>
18-
</testsuite>
19-
</testsuites>
15+
<testsuites>
16+
<testsuite name="JSON Schema Test Suite">
17+
<directory>tests</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<filter>
22+
<whitelist>
23+
<directory>./src/JsonSchema/</directory>
24+
</whitelist>
25+
</filter>
2026
</phpunit>

src/JsonSchema/Undefined.php

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)