Skip to content

Make validation exception more informative. #22

@swirtSJW

Description

@swirtSJW

As a person that has to debug validation failures, it would be helpful if the exception provided more details about what validation failed

Currently any failed validation says

RootedData\Exception\ValidationException: JSON Schema validation failed.

I am suggesting we iterate through the errors and list them so the output of the exception would be

RootedData\Exception\ValidationException: JSON Schema validation failed.
 1) data -> describedByType: application/pdf

Reproduction steps

Reproducing this is challenging as you need to start with invalid schema which is hard to save, because we don't allow invalid data.

  1. First you need a dataset json that is invalid. (an empty downloadUrl or a describedByType = 7)
  2. Then you can run it through $this->validMetadataFactory->get($json_string, $schema_id)
  3. This should result in a validation exception being thrown. Without the PR it will just tell you it failed validation, with the PR it will tell you what element(s) and values filed validation.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions