for-GET / jesse

jesse (JSon Schema Erlang) is an implementation of a JSON Schema validator for Erlang.
https://github.com/for-get/jesse
Apache License 2.0
124 stars 64 forks source link

[#90] Improve error messages (alternative) #92

Closed jfacorro closed 4 years ago

jfacorro commented 4 years ago

This PR is an alternative to the approach taken in PR #91.

The difference is that in this PR, when a oneOf validation fails, the returned errors include all of the validation errors from each schema in the list of the oneOf schema.

seriyps commented 4 years ago

Since we now have 2 versions to choose, I think it's generally better to present more information to the user and let them decide what to do with it. The only potential issue is that the error report for big nested *Of schemas risks to be really huge, because each sub-error includes their part of the schema. It can explode receiver process heap size if sent to another process (eg, logger) or written to ETS or sent via distribution. I think we can merge this PR and disregard #91 for now. Maybe adding an option to tune *Of error reporting in the follow-ups. Any opinions? @andreineculau maybe?

seriyps commented 4 years ago

Diff between 2 PRs:

https://github.com/jfacorro/jesse/compare/90-improve-error-messages...jfacorro:90-improve-error-messages-one-of-return-all-messages

seriyps commented 4 years ago

Thanks! I think the explanation about anyOf makes sense and we can add allOf later if someone asks.