Closed ghost closed 3 months ago
This was existing in the first version of the library, which was otherwise so much worse.
The problem is that with the error message callback you'd get message of failing combination-items which would be difficult to understand.
And I assume furthermore you would not want the error messages of failing combination-items if another one would be successful. So we would need to filter.
I might try something.
I tried something and I have it on a local branch. Note to myself.
Hi @pboettch , did you ever revisit this issue on your local branch?
@gabor-varga Yes I still have it on local. Would you mind testing and using it to see whether it fills the needs? I have to say it's quite verbose and only human readable.
I pushed an 'error-check'-branch which contains a change printing sub-schema errors if the logical-combination has failed.
Thanks @pboettch , I will check it. I basically want to find a way to print meaningful error messages on validation error that lets the user debug their config. We have quite complex schemas with many one_of
.
Thank you @pboettch , I will try to use and test it as well.
Hi @pboettch, have there been there any updates on the issue since January? Have you considered merging the branch to master? Also, with my github account, I can't find the branch called error-check
, has it been deleted since, or is it private?
It seems I forgot to push it.
Done.
Hi @pboettch, I've tested a bit your error-check
branch and found it quite useful.
Do you plan on merging this to master?
Hi @pboettch,
I also checked the error-check
branch, but the solution is not exactly what we were looking for.
I've found two issues:
anyOf
, and inside it an another anyOf
, the messages will be generated only for the first anyOf
.
There will be no detailed error messages generated for the deeper anyOf
levels. (Or for any logical combination types).pointer
and the instance
informations about the error, since they will be all packed into the message
.I have a proposal for fixing these issues and have all of the logical combination error messages: https://github.com/zecoaat/json-schema-validator
For the default error handler it works like earlier - only the root logical combination error will be thrown.
However, if you install a custom error handler, you can get all the details about the various cases:
no subschema has succeeded, but one of them is required to validate. Type: anyOf, number of failed subschemas: 3
[combination: anyOf / case#0] no subschema has succeeded, but one of them is required to validate. Type: anyOf, number of failed subschemas: 2
[combination: anyOf / case#0] [combination: anyOf / case#0] instance is below minimum of 5
[combination: anyOf / case#0] [combination: anyOf / case#1] instance is not a multiple of 2.0
[combination: anyOf / case#1] unexpected instance type
[combination: anyOf / case#2] unexpected instance type
(You can find the schema used for this test in the fork-project in tests.)
Please review the changes and consider merging this fork into the upstream project. Thank you in advance, Jimmy
@zecoaat Do not hesite to make a pull-request here! Your work's output looks nice.
@pboettch I created the pull request for the modifications: https://github.com/pboettch/json-schema-validator/pull/310
Fixed with #310. Thanks @zecoaat .
Hello,
In current version class logical_combination reports generic error after evaluation of all variants of subschema. It would be nice to add an option to log errors from individual subschemas as well if overall validation fails.