fixed README, fixed required/optional (optional is default)

This commit is contained in:
digitalkaoz 2011-12-09 14:18:59 +01:00
parent b54c0e6ea1
commit fe3da56869
2 changed files with 13 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...');
}
}
```

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");
}
}