karenetheridge / JSON-Schema-Modern

Validate data against a schema using a JSON Schema
https://metacpan.org/release/JSON-Schema-Modern/
Other
11 stars 1 forks source link

output formats: heirarchical error, annotation formats #24

Open karenetheridge opened 4 years ago

karenetheridge commented 4 years ago

The "detailed" format can be constructed from the flat list by decorating an object using the json pointers from each item's schema_location property as the json pointer and the value as the value.

The "verbose" format requires the annotations or errors we would otherwise throw away in failed or passing branches, so we need to construct this actually during traversal -- so that format needs to be requested in advance. I'm thinking that we track this result structure without blessed objects (just shove it into the ::Result object later), and construct it inside _eval after each _eval_keyword_$name method (so we will have to pass in new @error and @annotation structures for each one, and save their contents before possibly throwing it away due to the other result being obtained overall).

karenetheridge commented 3 years ago

This is much easier than I thought. each _eval can construct and return a slightly modified ::Result object (containing all the annotations or errors returned so far) which can recursively contain ::Result objects from lower subschemas. then ::Result->TO_JSON can serialize the nested structure (for verbose), or selectively remove redundant layers (for detailed).

karenetheridge commented 3 years ago

at the same time, json-schema-spec/output/schema.json needs a lot of work to fix the deficiencies therein.