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

Use JSON Pointer for ValidationMessage.path() #58

Closed
ehrmann opened this issue Jan 16, 2018 · 3 comments
Closed

Use JSON Pointer for ValidationMessage.path() #58

ehrmann opened this issue Jan 16, 2018 · 3 comments

Comments

@ehrmann
Copy link
Contributor

ehrmann commented Jan 16, 2018

Currently, paths are built in a format like $.foo.bar[0]. It's almost like jq, but not quite.

What are your thoughts on using an RFC-6901 JSON Pointer instead? The format looks more like /foo/bar/0. It's supported out-of-the-box by Jackson, and it resolves ambiguities with characters like [ and . being in field names.

It's something I can open a PR for, but I wanted to ask your opinion before doing the work.

@stevehu
Copy link
Contributor

stevehu commented Jan 16, 2018

@ehrmann It is JSONPath format and I think it is more powerful than JSON Pointer at the moment. In my light-bot project I am building test integration test cases and use JSON Path to assert the error messages. There is no RFC for JSONPath but I think it is used more often than JSON Pointer at the moment. In my opinion, we should support both and let end user to choose which format they want in the ValidationMessage. To ensure that the current users won't be impacted, let's make the JSONPath as default. Here is a link that is discussing these two.

https://www.tbray.org/ongoing/When/201x/2017/04/14/JsonPath-Needs-Work

@ehrmann
Copy link
Contributor Author

ehrmann commented Jan 16, 2018

Supporting both is reasonable enough. The only thing with JSONPath is that you don't actually need the flexibility here. Validation errors happen on nodes that can be accessed just by index and property. Index slicing, relative paths, and filters don't help much, here. That's also the reason JSON Pointer hasn't seen much use; it doesn't really do much.

@stevehu
Copy link
Contributor

stevehu commented Jan 16, 2018

I am planning to refactor this library with config and service. Once it is done, it will be very easy for users to replace any implementations in service.yml config file. Not just for the path builder but also validators etc. The only problem with me is there is no time :)

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