From 8868164fa6001c706dfb7673b839c3f8ceda9c7f Mon Sep 17 00:00:00 2001 From: Erayd Date: Thu, 23 Feb 2017 10:01:53 +1300 Subject: [PATCH] Clarify source of schema validation errors --- src/JsonSchema/Constraints/SchemaConstraint.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/JsonSchema/Constraints/SchemaConstraint.php b/src/JsonSchema/Constraints/SchemaConstraint.php index 344bf72a..202b867f 100644 --- a/src/JsonSchema/Constraints/SchemaConstraint.php +++ b/src/JsonSchema/Constraints/SchemaConstraint.php @@ -75,7 +75,12 @@ public function check(&$element, $schema = null, JsonPointer $path = null, $i = $validator = new Validator(new Factory($schemaStorage, null, self::CHECK_MODE_TYPE_CAST)); $validator->validate($validationSchema, $schemaStorage->getSchema($schemaSpec)); if (!$validator->isValid()) { - $this->addErrors($validator->getErrors()); + $validationErrors = array_map(function ($error) { + $error['message'] = 'Schema validation: ' . $error['message']; + + return $error; + }, $validator->getErrors()); + $this->addErrors($validationErrors); $this->addError($path, 'Schema is not valid', 'schema'); } }