Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement output formatting from Draft 2019-09 #100

Closed
2 of 4 tasks
Stranger6667 opened this issue Jun 7, 2020 · 5 comments
Closed
2 of 4 tasks

Implement output formatting from Draft 2019-09 #100

Stranger6667 opened this issue Jun 7, 2020 · 5 comments

Comments

@Stranger6667
Copy link
Owner

Stranger6667 commented Jun 7, 2020

https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-02#section-10

It does seem like a good way to standardize error output, regardless of the used schema version.

@driv3r
Copy link

driv3r commented Mar 30, 2021

Hey @Stranger6667 ! I wanted to look into this issue, any up front pointers would be awesome.

@Stranger6667
Copy link
Owner Author

Hi @driv3r !

Thank you for taking a step :) My initial plan was:

  • store paths inside validators (as String or Vec<String>, not sure which one is more convenient). So, each validator knows its location within the schema.
  • have a pointer (Vec<String> - JSON Pointer chunks) to a part of data being validated. This one could not be necessary in all cases, as we often can derive it from the current validator path. Skipping it for such cases seems like optimization to me and can be done later.
  • If an error happens, then ValidationError might take the validator's path & pointer to the current data part
  • Implement a function on ErrorIterator (probably requires making it a separate struct & implementing IntoIterator on it) that will take some kind of "format" enum value that will consume the iterator and transform those errors into the desired format.

Let me know if I can provide more info

@driv3r
Copy link

driv3r commented Mar 30, 2021

I assume we can get the path from the Context.scope I saw that it's available during validator compilation phase or should I look for something else?

@Stranger6667
Copy link
Owner Author

Partially - it only changes when sub-folders are involved (via $id / id keywords), but it can be changed to keep track of all steps! :)

Also, it might be a bit tricky when the scope changes to another document (e.g. a remote one in the $ref keyword implementation), so we need to have all chunks that will lead to the root document.

But I think it is the right direction indeed :)

@Stranger6667
Copy link
Owner Author

flag and basic styles were implemented via #274

I'll put detailed & verbose to separate issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants