mirror of
https://github.com/justinrainbow/json-schema.git
synced 2025-03-18 13:19:41 +01:00
fixed README, fixed required/optional (optional is default)
This commit is contained in:
parent
b54c0e6ea1
commit
fe3da56869
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...');
|
||||
}
|
||||
}
|
||||
```
|
@ -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