From fe3da568690858973ba727a5e3aa808c615b99df Mon Sep 17 00:00:00 2001 From: digitalkaoz Date: Fri, 9 Dec 2011 14:18:59 +0100 Subject: [PATCH] fixed README, fixed required/optional (optional is default) --- README.md | 20 ++++++++++++-------- libs/JsonSchema.php | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8e63f25..6a94004 100644 --- a/README.md +++ b/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 +valid) { die('success!'); - } - else { +} +else { die('fail...'); - } +} +``` \ No newline at end of file diff --git a/libs/JsonSchema.php b/libs/JsonSchema.php index d5e0671..a324a3e 100644 --- a/libs/JsonSchema.php +++ b/libs/JsonSchema.php @@ -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"); } }