Skip to content

xpath like string in error message. #14

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

Closed
ghost opened this issue Jun 18, 2012 · 1 comment
Closed

xpath like string in error message. #14

ghost opened this issue Jun 18, 2012 · 1 comment
Labels
Enhancement Some new desired functionality

Comments

@ghost
Copy link

ghost commented Jun 18, 2012

The error message in the current ValidationError is not helpful in identifying the invalid tag.

The validator raises error message such as these:

Error1: ["u'name' is a required property"]

We need a better way to identify such errors.
I propose we use a jsonpath-like[1] string that indicates the "path" to the invalid tag.

Ex.

x["persons"][0]["location"]["city"]

In a document like this:

{
  "persons": [
    {
      "location": {
        "city": "New York"
     }
   }
  ]
}

Having this "jsonpath" will aslo make it posible to indicate the row and the line the error has occurred on if you have some sort of tag database.

I am more then willing to implement this feature myself, but I require some pointers to get started.
I am looking for the functions that get called when someone starts validating a new element from an array or a tag from an object.

These functions need to be recursive so I can easily track the parents of the current tag.
Basically to use the function stack as a way to infer the parents of a tag.

[1] http://goessner.net/articles/JsonPath/

@Julian
Copy link
Member

Julian commented Jun 18, 2012

Closing as a duplicate of #5 and #12 :).

An implementation detail was making this a bit difficult to do cleanly, but that should be sorted now. So, this should hit for the next release. In fact, I was just pushing out a commit with preliminary support, feel free to try it and let me know how it goes.

Feel free to reopen if you've got more in mind.

@Julian Julian closed this as completed Jun 18, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Some new desired functionality
Projects
None yet
Development

No branches or pull requests

1 participant