mirror of
https://github.com/justinrainbow/json-schema.git
synced 2025-03-18 21:29:46 +01:00
Merge pull request #1 from digitalkaoz/composer_json
Composer json and schema fix
This commit is contained in:
commit
c5d3203846
20
README.md
20
README.md
@ -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
19
composer.json
Normal 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/"}
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user