Skip to content

Commit

Permalink
Clarify source of schema validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
erayd committed Feb 23, 2017
1 parent e661e53 commit 8868164
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/JsonSchema/Constraints/SchemaConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Expand Down

0 comments on commit 8868164

Please sign in to comment.