-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
equality between properties #1419
Comments
Unfortunately, this is one of the things JSON Schema isn't currently capable of expressing. We would need a new keyword similar to |
@vasile-baluta are you asking to validate whether any two properties have the same values, or just that If the first (all unique property values), then what @jdesrosiers said. If the second (just A schema that would invalidate the instance you posted would be something like this: {
"$schema": "https://json-everything.net/meta/data-2022",
"type": "object",
"properties": {
"property1": { "type": "string" },
"property2": {
"type": "string",
"not": {
"data": {
"const": "/property1"
}
}
}
}
} The link to the vocabulary above explains how this works in a bit more detail, but basically, the values of So this says
My hope is that eventually other implementations will support this vocabulary, but I haven't seen that yet. You can test this on https://json-everything.net/json-schema. |
Thanks @gregsdennis ! I use Python and I solved it using a custom validator but I plan to create a repository at GitHub to show my solution. BR |
@vasile-baluta it would be helpful for the project if we understood your need so that we can decide whether a proper solution needs to be added to JSON Schema. If you can find the time, we'd appreciate a summary. Otherwise, I think I'll close this issue as resolved. |
Hi!
If I have json like this
{
"property1": "value1",
"property2": "value1"
}
How will a schema look like that invalidates the json if property1 has same value as property2?
The text was updated successfully, but these errors were encountered: