From 62e1811ddb1455ea7eab905bc616c2c2ec9cf4de Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Tue, 23 Jul 2013 16:23:15 -0400 Subject: [PATCH 1/5] Added draft 04 option (and made it default) --- src/Pyrus/JsonSchema/JSV.php | 19 +- src/Pyrus/JsonSchema/JSV/Schema/Draft04.php | 260 ++++++++++++++++++++ 2 files changed, 270 insertions(+), 9 deletions(-) create mode 100644 src/Pyrus/JsonSchema/JSV/Schema/Draft04.php diff --git a/src/Pyrus/JsonSchema/JSV.php b/src/Pyrus/JsonSchema/JSV.php index d3b5792..81b1309 100644 --- a/src/Pyrus/JsonSchema/JSV.php +++ b/src/Pyrus/JsonSchema/JSV.php @@ -84,7 +84,7 @@ function is_json_array($i) class JSV { static protected $_environments = array(); - static protected $_defaultEnvironmentID = ""; + static protected $_defaultEnvironmentID = "json-schema-draft-04"; /** * Creates and returns a new {@link Environment} that is a clone of the environment registered with the provided ID. @@ -104,14 +104,15 @@ static function createEnvironment($id) if (!isset(static::$_environments[$id])) { switch ($id) { // lazy load - case 'json-schema-draft-03' : - case 'json-schema-draft-02' : - case 'json-schema-draft-01' : - $class = __NAMESPACE__ . '\JSV\Schema\\' . ucfirst(str_replace(array('json-schema-', '-'), '', $id)); - new $class; - break; - default: - throw new Exception("Unknown Environment ID: $id"); + case 'json-schema-draft-04': + case 'json-schema-draft-03' : + case 'json-schema-draft-02' : + case 'json-schema-draft-01' : + $class = __NAMESPACE__ . '\JSV\Schema\\' . ucfirst(str_replace(array('json-schema-', '-'), '', $id)); + new $class; + break; + default: + throw new Exception("Unknown Environment ID: $id"); } } //else diff --git a/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php b/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php new file mode 100644 index 0000000..a2caf3f --- /dev/null +++ b/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php @@ -0,0 +1,260 @@ +draft1 = new Draft03(); + + return parent::__construct($register); + } + + function initializeEnvironment(){ + $this->ENVIRONMENT = new Environment(); + $this->ENVIRONMENT->setOption("validateReferences", true); + $this->ENVIRONMENT->setOption("defaultSchemaURI", "http://json-schema.org/draft-04/schema#"); + + //prevent reference errors + $this->ENVIRONMENT->createSchema(array(), true, "http://json-schema.org/draft-04/schema#"); + $this->ENVIRONMENT->createSchema(array(), true, "http://json-schema.org/draft-04/hyper-schema#"); + $this->ENVIRONMENT->createSchema(array(), true, "http://json-schema.org/draft-04/links#"); + + } + + function initializeSchema($uri = "http://json-schema.org/draft-04/schema#"){ + return parent::initializeSchema($uri); + } + + function initializeHyperSchema($uri1 = "http://json-schema.org/draft-04/hyper-schema#", $uri2 = "http://json-schema.org/draft-04/hyper-schema#"){ + return parent::initializeHyperSchema($uri1, $uri2); + } + + function initializeLinks($uri = "http://json-schema.org/draft-04/links#"){ + return parent::initializeLinks($uri); + } + + function registerSchemas(){ + //We need to reinitialize these schemas as they reference each other + $this->HYPERSCHEMA = $this->ENVIRONMENT->createSchema($this->HYPERSCHEMA->getValue(), $this->HYPERSCHEMA, + "http://json-schema.org/draft-04/hyper-schema#"); + + $this->ENVIRONMENT->setOption("latestJSONSchemaSchemaURI", "http://json-schema.org/draft-04/schema#"); + $this->ENVIRONMENT->setOption("latestJSONSchemaHyperSchemaURI", "http://json-schema.org/draft-04/hyper-schema#"); + $this->ENVIRONMENT->setOption("latestJSONSchemaLinksURI", "http://json-schema.org/draft-04/links#"); + + // + //Latest JSON Schema + // + + //Hack, but WAY faster then instantiating a new schema + $this->ENVIRONMENT->replaceSchema("http://json-schema.org/schema#", $this->SCHEMA); + $this->ENVIRONMENT->replaceSchema("http://json-schema.org/hyper-schema#", $this->HYPERSCHEMA); + $this->ENVIRONMENT->replaceSchema("http://json-schema.org/links#", $this->LINKS); + + // + //register environment + // + + $this->ENVIRONMENT->setOption("defaultFragmentDelimiter", "/"); + JSV::registerEnvironment("json-schema-draft-03", $this->ENVIRONMENT); + if (!JSV::getDefaultEnvironmentID() || JSV::getDefaultEnvironmentID() === "json-schema-draft-01" + || JSV::getDefaultEnvironmentID() === "json-schema-draft-02" + || JSV::getDefaultEnvironmentID() === "json-schema-draft-03") { + JSV::setDefaultEnvironmentID("json-schema-draft-04"); + } + } + + function getSchemaArray(){ + $SCHEMA_03_JSON = $this->draft3->getSchemaArray(); + $propertiesparser = $SCHEMA_03_JSON["properties"]["properties"]["parser"]; + $extendsparser = $SCHEMA_03_JSON["properties"]["extends"]["parser"]; + + $diff = array('$schema' => "http://json-schema.org/draft-04/schema#", + 'id' => "http://json-schema.org/draft-04/schema#", + 'properties' => + array('multipleOf' => + array('type' => 'number', + 'minimum' => 1, + 'validator' => + function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ + if (is_numeric($instance->getValue())){ + $multipleOf = $schema->getAttribute("multipleOf"); + if(is_numeric($multipleOf) && $instance->getValue() % $multipleOf !== 0){ + $report->addError($instance, $schema, "multipleOf", + "Number is not a multiple of the required multiple value" . + " [schema path: $instance->getPath()]", $minimum); + } + } + }), + 'maxProperties' => + array('type' => 'integer', + 'minimum' => 0, + 'validator' => + function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ + $maxProperties = $schema->getAttribute("maxProperties"); + if(is_int($maxProperties) && count($instance->getValue()) > $maxProperties){ + $report->addError($instance, $schema, "maxProperties", + "Object has more than the required maximum properties" . + " [schema path: $instance->getPath()]", $maxProperties); + } + }), + 'minProperties' => + array('type' => 'integer', + 'minimum' => 0, + 'validator' => + function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ + $minProperties = $schema->getAttribute("minProperties"); + if(is_int($minProperties) && count($instance->getValue()) > $maxProperties){ + $report->addError($instance, $schema, "minProperties", + "Object has fewer than the required minimum properties" . + " [schema path: $instance->getPath()]", $minProperties); + } + }), + 'required' => + array('type' => 'array', + 'default' => array(), + 'validator' => + function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ + if(JS\is_json_object($instance->getValue())){ + $required = $schema->getAttribute("required"); + foreach($required as $req){ + if($instance->getProperty($req) === null){ + $report->addError($instance, $schema, "required", + "Required property \"$req\" not provided" . + " [schema path: $instance->getPath()]", $required); + } + } + } + }), + 'allOf' => + array('type' => 'array', + 'default' => array(), + 'minItems' => 1, + 'parser' => $extendsparser, + 'validator' => + function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ + $subschemas = $schema->getAttribute("allOf"); + if (JS\is_json_array($subschemas)){ + foreach($subschemas as $subschema){ + $subschema->validate($instance, $report, $parent, $parentSchema, $name); + } + } + }), + 'anyOf' => + array('type' => 'array', + 'default' => array(), + 'minItems' => 1, + 'parser' => $extendsparser, + 'validator' => + function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ + $subschemas = $schema->getAttribute("anyOf"); + if(JS\is_json_array($subschemas)){ + if(empty($subschemas)){ + return; + } + foreach($subschemas as $subschema){ + $temp_report = new Report(); + $subschema->validate($instance, $temp_report, $parent, $parentSchema, $name); + if(empty($temp_report->errors)){ + return; + } + } + $report->addError($instance, $schema, "anyOf", + "Object did not match any element of the 'anyOf' array" . + " [schema path: $instance->getPath()]", $subschemas); + } + }), + 'oneOf' => + array('type' => 'array', + 'default' => array(), + 'minItems' => 1 + 'parser' => $extendsparser, + 'validator' => + function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ + $subschemas = $schema->getAttribute("oneOf"); + if(JS\is_json_array($subschemas)){ + $found = false; + foreach($subschemas as $subschema){ + $temp_report = new Report(); + $subschema->validate($instance, $temp_report, $parent, $parentSchema, $name); + if(empty($temp_report->errors)){ + if($found){ + $report->addError($instance, $schema, "oneOf", + "Object matched more than one element of the 'oneOf' array" . + " [schema path: $instance->getPath()", $subschemas); + } else { + $found = true; + } + } + } + $report->addError($instance, $schema, "oneOf", + "Object did not match any element of the 'oneOf' array" . + " [schema path: $instance->getPath()]", $subschemas); + } + }), + 'not' => + array('type' => 'array', + 'default' => array(), + 'minItems' => 1 + 'parser' => $extendsparser, + 'validator' => + function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ + $subschemas = $schema->getAttribute("not"); + if(JS\is_json_array($subschemas)){ + foreach($subschemas as $subschema){ + $temp_report = new Report(); + $subschema->validate($instance, $temp_report, $parent, $parentSchema, $name); + if(empty($temp_report->errors)){ + $report->addError($instance, $schema, "oneOf", + "Object matched an element of the 'not' array" . + " [schema path: $instance->getPath()", $subschemas); + } + } + } + }))); + return JSV::inherits($SCHEMA_03_JSON, $diff); + } + + function getHyperSchemaArray() + { + $arr = $this->draft3->getHyperSchemaArray(); + $arr['$schema'] = "http://json-schema.org/draft-04/hyper-schema#"; + $arr['id'] = "http://json-schema.org/draft-04/hyper-schema#"; + $arr['properties']['links']['selfReferenceVariable'] = '@'; + $arr['properties']['root']['deprecated'] = true; + $arr['properties']['contentEncoding']['deprecated'] = false; + $arr['properties']['alternate']['deprecated'] = true; + return $arr; + } + + function getLinksArray() + { + $arr = $this->draft2->getLinksArray(); + $arr['$schema'] = "http://json-schema.org/draft-04/hyper-schema#"; + $arr['id'] = "http://json-schema.org/draft-04/links#"; + + $arr['properties']['href']['required'] = true; + $arr['properties']['format'] = 'link-description-object-template'; + $arr['properties']['rel']['required'] = true; + $arr['properties']['properties']['deprecated'] = true; + $arr['schema']['$ref'] = "http://json-schema.org/draft-04/hyper-schema#"; + return $arr; + } +} \ No newline at end of file From e6b83e031005aa9fd9f7b106a9277b4802668cc7 Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Wed, 24 Jul 2013 10:18:15 -0400 Subject: [PATCH 2/5] Fixed default createEnvironment parameter --- src/Pyrus/JsonSchema/JSV.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pyrus/JsonSchema/JSV.php b/src/Pyrus/JsonSchema/JSV.php index 81b1309..0a958fc 100644 --- a/src/Pyrus/JsonSchema/JSV.php +++ b/src/Pyrus/JsonSchema/JSV.php @@ -96,7 +96,7 @@ class JSV * @return class JsonSchema\Environment environment object */ - static function createEnvironment($id) + static function createEnvironment($id=NULL) { if (!$id) { $id = static::$_defaultEnvironmentID; From 9a96e745b03803cf2264ce2d64a7c57ac0c8f35f Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Wed, 24 Jul 2013 11:46:46 -0400 Subject: [PATCH 3/5] Fixed loading, syntax errors, a bug --- .gitignore | 6 ++- src/Loader.php | 6 +++ src/Pyrus/JsonSchema/JSV.php | 2 +- src/Pyrus/JsonSchema/JSV/Schema/Draft04.php | 43 ++++++++++----------- 4 files changed, 32 insertions(+), 25 deletions(-) create mode 100644 src/Loader.php diff --git a/.gitignore b/.gitignore index ce31fbc..e4ca311 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -JsonSchema.komodoproject \ No newline at end of file +JsonSchema.komodoproject + +## Emacs: +\#*\# +*~ \ No newline at end of file diff --git a/src/Loader.php b/src/Loader.php new file mode 100644 index 0000000..693ee51 --- /dev/null +++ b/src/Loader.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/src/Pyrus/JsonSchema/JSV.php b/src/Pyrus/JsonSchema/JSV.php index 0a958fc..49feef4 100644 --- a/src/Pyrus/JsonSchema/JSV.php +++ b/src/Pyrus/JsonSchema/JSV.php @@ -109,7 +109,7 @@ static function createEnvironment($id=NULL) case 'json-schema-draft-02' : case 'json-schema-draft-01' : $class = __NAMESPACE__ . '\JSV\Schema\\' . ucfirst(str_replace(array('json-schema-', '-'), '', $id)); - new $class; + return new $class; break; default: throw new Exception("Unknown Environment ID: $id"); diff --git a/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php b/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php index a2caf3f..3a08220 100644 --- a/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php +++ b/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php @@ -18,11 +18,8 @@ Pyrus\JsonSchema\JSV, Pyrus\JsonSchema as JS; class Draft04 extends Draft03{ - var $draft3; function __costruct($register = true){ - $this->draft1 = new Draft03(); - return parent::__construct($register); } @@ -82,7 +79,7 @@ function registerSchemas(){ } function getSchemaArray(){ - $SCHEMA_03_JSON = $this->draft3->getSchemaArray(); + $SCHEMA_03_JSON = parent::getSchemaArray(); $propertiesparser = $SCHEMA_03_JSON["properties"]["properties"]["parser"]; $extendsparser = $SCHEMA_03_JSON["properties"]["extends"]["parser"]; @@ -184,7 +181,7 @@ function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ 'oneOf' => array('type' => 'array', 'default' => array(), - 'minItems' => 1 + 'minItems' => 1, 'parser' => $extendsparser, 'validator' => function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ @@ -212,7 +209,7 @@ function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ 'not' => array('type' => 'array', 'default' => array(), - 'minItems' => 1 + 'minItems' => 1, 'parser' => $extendsparser, 'validator' => function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ @@ -234,27 +231,27 @@ function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ function getHyperSchemaArray() { - $arr = $this->draft3->getHyperSchemaArray(); - $arr['$schema'] = "http://json-schema.org/draft-04/hyper-schema#"; - $arr['id'] = "http://json-schema.org/draft-04/hyper-schema#"; - $arr['properties']['links']['selfReferenceVariable'] = '@'; - $arr['properties']['root']['deprecated'] = true; - $arr['properties']['contentEncoding']['deprecated'] = false; - $arr['properties']['alternate']['deprecated'] = true; - return $arr; + $arr = parent::getHyperSchemaArray(); + $arr['$schema'] = "http://json-schema.org/draft-04/hyper-schema#"; + $arr['id'] = "http://json-schema.org/draft-04/hyper-schema#"; + $arr['properties']['links']['selfReferenceVariable'] = '@'; + $arr['properties']['root']['deprecated'] = true; + $arr['properties']['contentEncoding']['deprecated'] = false; + $arr['properties']['alternate']['deprecated'] = true; + return $arr; } function getLinksArray() { - $arr = $this->draft2->getLinksArray(); - $arr['$schema'] = "http://json-schema.org/draft-04/hyper-schema#"; - $arr['id'] = "http://json-schema.org/draft-04/links#"; + $arr = parent::getLinksArray(); + $arr['$schema'] = "http://json-schema.org/draft-04/hyper-schema#"; + $arr['id'] = "http://json-schema.org/draft-04/links#"; - $arr['properties']['href']['required'] = true; - $arr['properties']['format'] = 'link-description-object-template'; - $arr['properties']['rel']['required'] = true; - $arr['properties']['properties']['deprecated'] = true; - $arr['schema']['$ref'] = "http://json-schema.org/draft-04/hyper-schema#"; - return $arr; + $arr['properties']['href']['required'] = true; + $arr['properties']['format'] = 'link-description-object-template'; + $arr['properties']['rel']['required'] = true; + $arr['properties']['properties']['deprecated'] = true; + $arr['schema']['$ref'] = "http://json-schema.org/draft-04/hyper-schema#"; + return $arr; } } \ No newline at end of file From 90a130342563d8ec7de299f3566cb00122949975 Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Wed, 24 Jul 2013 14:50:44 -0400 Subject: [PATCH 4/5] Fixed bugs --- src/Loader.php | 4 ++-- src/Pyrus/JsonSchema/JSV.php | 2 +- src/Pyrus/JsonSchema/JSV/Schema/Draft04.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Loader.php b/src/Loader.php index 693ee51..285b47b 100644 --- a/src/Loader.php +++ b/src/Loader.php @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/src/Pyrus/JsonSchema/JSV.php b/src/Pyrus/JsonSchema/JSV.php index 49feef4..0a958fc 100644 --- a/src/Pyrus/JsonSchema/JSV.php +++ b/src/Pyrus/JsonSchema/JSV.php @@ -109,7 +109,7 @@ static function createEnvironment($id=NULL) case 'json-schema-draft-02' : case 'json-schema-draft-01' : $class = __NAMESPACE__ . '\JSV\Schema\\' . ucfirst(str_replace(array('json-schema-', '-'), '', $id)); - return new $class; + new $class; break; default: throw new Exception("Unknown Environment ID: $id"); diff --git a/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php b/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php index 3a08220..180117e 100644 --- a/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php +++ b/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php @@ -70,7 +70,7 @@ function registerSchemas(){ // $this->ENVIRONMENT->setOption("defaultFragmentDelimiter", "/"); - JSV::registerEnvironment("json-schema-draft-03", $this->ENVIRONMENT); + JSV::registerEnvironment("json-schema-draft-04", $this->ENVIRONMENT); if (!JSV::getDefaultEnvironmentID() || JSV::getDefaultEnvironmentID() === "json-schema-draft-01" || JSV::getDefaultEnvironmentID() === "json-schema-draft-02" || JSV::getDefaultEnvironmentID() === "json-schema-draft-03") { From c33c1995de9149afed4ea68d7dfd8c349ea349a6 Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Wed, 24 Jul 2013 16:31:14 -0400 Subject: [PATCH 5/5] Improved error handling --- src/Pyrus/JsonSchema/JSV/Schema/Draft04.php | 36 +++++++++++++-------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php b/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php index 180117e..886082b 100644 --- a/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php +++ b/src/Pyrus/JsonSchema/JSV/Schema/Draft04.php @@ -96,7 +96,7 @@ function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ if(is_numeric($multipleOf) && $instance->getValue() % $multipleOf !== 0){ $report->addError($instance, $schema, "multipleOf", "Number is not a multiple of the required multiple value" . - " [schema path: $instance->getPath()]", $minimum); + " [schema path: " . $instance->getPath() . "]", $minimum); } } }), @@ -109,7 +109,7 @@ function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ if(is_int($maxProperties) && count($instance->getValue()) > $maxProperties){ $report->addError($instance, $schema, "maxProperties", "Object has more than the required maximum properties" . - " [schema path: $instance->getPath()]", $maxProperties); + " [schema path: " . $instance->getPath() . "]", $maxProperties); } }), 'minProperties' => @@ -121,7 +121,7 @@ function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ if(is_int($minProperties) && count($instance->getValue()) > $maxProperties){ $report->addError($instance, $schema, "minProperties", "Object has fewer than the required minimum properties" . - " [schema path: $instance->getPath()]", $minProperties); + " [schema path: " . $instance->getPath() . "]", $minProperties); } }), 'required' => @@ -135,7 +135,7 @@ function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ if($instance->getProperty($req) === null){ $report->addError($instance, $schema, "required", "Required property \"$req\" not provided" . - " [schema path: $instance->getPath()]", $required); + " [schema path: " . $instance->getPath() . "]", $required); } } } @@ -169,13 +169,13 @@ function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ foreach($subschemas as $subschema){ $temp_report = new Report(); $subschema->validate($instance, $temp_report, $parent, $parentSchema, $name); - if(empty($temp_report->errors)){ + if(!count($temp_report->errors)){ return; } } $report->addError($instance, $schema, "anyOf", "Object did not match any element of the 'anyOf' array" . - " [schema path: $instance->getPath()]", $subschemas); + " [schema path: " . $instance->getPath() . "]", $subschemas); } }), 'oneOf' => @@ -187,23 +187,33 @@ function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ $subschemas = $schema->getAttribute("oneOf"); if(JS\is_json_array($subschemas)){ + $temp_full_report = new Report(); $found = false; foreach($subschemas as $subschema){ $temp_report = new Report(); $subschema->validate($instance, $temp_report, $parent, $parentSchema, $name); - if(empty($temp_report->errors)){ + if(!count($temp_report->errors)){ if($found){ $report->addError($instance, $schema, "oneOf", "Object matched more than one element of the 'oneOf' array" . - " [schema path: $instance->getPath()", $subschemas); + " [schema path: " . $instance->getPath() . "]", $subschemas); + return; } else { $found = true; } + } else { + $temp_full_report->errors = array_merge($temp_full_report->errors, + $temp_report->errors); } } - $report->addError($instance, $schema, "oneOf", - "Object did not match any element of the 'oneOf' array" . - " [schema path: $instance->getPath()]", $subschemas); + if(!$found){ + $report->addError($instance, $schema, "oneOf", + "Object did not match any element of the 'oneOf' array" . + " [schema path: " . $instance->getPath() . "]", $subschemas); + $report->errors = array_merge($report->errors, + $temp_full_report->errors); + } + } }), 'not' => @@ -218,10 +228,10 @@ function ($instance, $schema, $self, $report, $parent, $parentSchema, $name){ foreach($subschemas as $subschema){ $temp_report = new Report(); $subschema->validate($instance, $temp_report, $parent, $parentSchema, $name); - if(empty($temp_report->errors)){ + if(!count($temp_report->errors)){ $report->addError($instance, $schema, "oneOf", "Object matched an element of the 'not' array" . - " [schema path: $instance->getPath()", $subschemas); + " [schema path: " . $instance->getPath() . "", $subschemas); } } }