Closed aldlfkahs closed 9 months ago
Additionally, I added fail_early
parameter to validate(json, reporter)
function for custom error reporter as well for personal use. If you also like this idea, I will make a PR for this too.
Thanks for contributing. I've merged in this PR, however, we're currently doing a major rewrite of jsonschema on a branch, with the intention of supporting later versions starting with 2019-09, so it's probably better to postpone more jsonschema related PR's on main, until we merge in the new code. We definitely want to improve error messages and reporting, and reporting requirements added in the 2019-09 draft will also be supported in the draft 7 implementation. Any thoughts for further improvements are most welcome, and I'll look at your other suggestion.
Just FYI, regarding your second suggestion for fail_early
, since version 0.175.0, the reporter passed to the json_schema<Json>::validate
functions must return walk_result::advance
or walk_result::abort
, this gives the user control over early exit. (The legacy classes and functions, make_schema
and json_validator
, are not affected.)
Great improvement! Thank you for sharing information of new release.
Default error reporter in jsonschema prints only
o.message()
which only shows the reason. I think it is not enough. Users cannot know where the error occurs. Many other json schema libraries aim for human-comprehensible error messages. So, how about print little bit more detail? I simply modified by addingo.instance_location()
, referred from custom error reporter example in jsonschema doc.