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

Include line and column info in a validation error #9

Closed
balasaalin opened this issue Oct 28, 2015 · 1 comment
Closed

Include line and column info in a validation error #9

balasaalin opened this issue Oct 28, 2015 · 1 comment

Comments

@balasaalin
Copy link

I would like to be able to locate the component from a JSON instance document that is invalid according to the schema rules.
I think this can be achieved if the validation error would contain the start line and column (or offset) of the invalid component from the instance document. It would be great if it is possible to also include the end line and column in order to fully locate the component.

@erosb
Copy link
Contributor

erosb commented Oct 29, 2015

Hello @balasaalin , the library performs the validation against JSONObject instances and not the raw JSON string. The JSONObject and JSONArray classes don't contain token information after they finish parsing the string, therefore the location of the invalid data fragment cannot be contained in the ValidationException. It has been designed this way because the JSONObject is not necessarily created by parsing a raw JSON but also can be created programmatically.

The best I can do for it is generating a JSON pointer pointing from the document root to the invalid data (see here: #6 ).

@erosb erosb closed this as completed Oct 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants