'Express that, for a given property value, a property with the same name should exist using json schema?

I'm trying to validate json files which have an element that has a property which contains a value that should exist in another part of the json. I'm using jsonschema Draft 07.

This is a simple little example that shows the scenario I'm trying to validate in my data.

{
  "objects": {
    "object1": {
      "colorKey": "orange"
    }
  },
  "colors": {
      "orange": {
          "red": "FF",
          "green": "AF",
          "blue": "00"
      }
  }
}

How can I validate that the 'value' of colorKey (in this case 'orange') actually exists as a property of the 'colors' object? The data isn't stored in arrays, just defined properties.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source