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

API to get corresponding schema path for data and path #198

Open
whitlockjc opened this issue Dec 4, 2017 · 2 comments
Open

API to get corresponding schema path for data and path #198

whitlockjc opened this issue Dec 4, 2017 · 2 comments

Comments

@whitlockjc
Copy link
Contributor

Let's say you have a JSON Schema document and an object being validated. What if I wanted to know what portion of the JSON Schema document corresponding to a particular path within the data being validated. For example:

JSON Schema

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    }
  }
}

Data

{
  "id": "some-uuid"
}

How can I get from ["id"] (the path in the data object) to ["properties", "id"] (the path in the JSON Schema document)? This is a very simple example and would become more complex based on nested schemas, arrays, etc.

I'm not saying there has to be an API provided by z-schema, just wondering what you think about something like this.

@zaggino
Copy link
Owner

zaggino commented Dec 6, 2017

Well, the errors should already point to place where the validation failed, so the API should be possible. You probably would need to propose an API, sample inputs/outputs and then we could see how the implementation could be done. It's been a while since I've worked on this so I don't remember the exacts.

@whitlockjc
Copy link
Contributor Author

Yes, for validation errors the path is there. I was just wondering about a more general API that isn't directly tied to validation.

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