-
-
Notifications
You must be signed in to change notification settings - Fork 292
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
Assert that value must appear once somewhere else in JSON #706
Comments
I call this kind of validation consistency validation because it involves checking that two pieces of data are consistent with each other. In other applications, this might also be called entailment, or other things. Typically we haven't dealt with this because it's very difficult to define completely. There might be mathematics or data operations involved, for example, and it's impractical to define a whole scripting language out of JSON. Another reason I'm skittish on this is I don't want to cause people to structure their JSON documents around the features of JSON Schema, and this feature might cause people to produce bloated JSON documents, when otherwise it'd be preferable to just write a standard database query. But there might be a generic way to define this, #549 suggests a property that can define data sources, and data references, and validators can implement user functions to verify a data reference points to a member of a data source. There might be a few other issues about this. Give me a few days to check, or maybe someone else remembers? This is a frequent enough question we should probably consider treating it in the spec text. |
Hi there,
As far as I know, this would be considered a feature request because I haven't found a way to do in via any features available in the current Draft-07 JSON Schema. The title of this issue sounds slightly strange, but the idea is extremely simple.
Consider the following JSON:
My aim is to have some schema-driven way of asserting that
favorite_animal
maps to anid
of one of the objects in theanimals
array. Specifically, it must map to exactly oneid
, but depending on how this is implemented, it could be implemented in the spirit of theoneOf
,anyOf
, andallOf
family of keywords.Is this already possible via some means of
$ref
and whatnot, or am I out of luck? If the latter, is this use case seem practical and useful enough to warrant crafting functionality for it in JSON Schema?Thanks,
Caleb
The text was updated successfully, but these errors were encountered: