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

Validate against enum derived from list of objects dynamically #887

Closed
sunnyofhell opened this issue Apr 3, 2020 · 1 comment
Closed

Comments

@sunnyofhell
Copy link

sunnyofhell commented Apr 3, 2020

Using JSON Schema 7 to perform validations

Is the below validation possible using json schema.

 {
    properties : [{name: "a"}, {name: "b"}, {name: "c"}],
    rules : [{ prop : ["a","b"] }, { prop : ["a"] }, {prop: ["c"]}]
 }

The "prop" property in object is dependent values in properties.

ie only of "properties.name" exists then that value can be added to the "prop" array

Note:

The "properties" array can have any object of type {name : }
"name" can have any possible string, which i don't know beforehand
I have been going through documentation, but can't find a answer.

Is this validation not supported in Json Schema yet? Any plans/workarounds for doing this?

@handrews
Copy link
Contributor

No, and no current plans. See json-schema-org/json-schema-vocabularies#26 for an in-depth discussion of keywords with external dependencies. I'm closing this because the general issue is well-covered elsewhere. And we wouldn't put such a keyword in the core JSON specification even if generally supported- it would be 3rd-party extension. My apologies if this is a little terse, we should probably have a better write-up somewhere that explains why we don't do this. I think there's one on the wiki but it's pretty abstract.

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