Merge pull request #1 from digitalkaoz/composer_json

Composer json and schema fix
This commit is contained in:
Justin Rainbow 2011-12-09 09:53:53 -08:00
commit c5d3203846
3 changed files with 32 additions and 9 deletions

View File

@ -2,13 +2,17 @@
## Usage
$json = json_decode($input_json);
$schema = json_decode($input_schema);
$result = JsonSchema::validate($json, $schema);
if ($result->valid) {
```php
<?php
$json = json_decode($input_json);
$schema = json_decode($input_schema);
$result = JsonSchema::validate($json, $schema);
if ($result->valid) {
die('success!');
}
else {
}
else {
die('fail...');
}
}
```

19
composer.json Normal file
View File

@ -0,0 +1,19 @@
{
"name": "justinrainbow/json-schema",
"description": "a library to validate a json schema"
"keywords": ["json", "schema"],
"homepage": "https://github.com/justinrainbow/json-schema",
"type": "library",
"license": "MIT",
"version": "1.0.0",
"authors": [
{
"name": "Justin Rainbow"
}
],
"autoload": {
"psr-0": { "JsonSchema": "libs/", "JsonSchemaUndefined": "libs/"}
}
}

View File

@ -169,7 +169,7 @@ class JsonSchema {
}
// verify optional values
if (is_object($value) && $value instanceOf JsonSchemaUndefined) {
if ( isset($schema->optional) ? !$schema->optional : true) {
if ( isset($schema->required) ? !$schema->required : true) {
self::adderror($path,"is missing and it is not optional");
}
}