Json schema to validate object's values against content of another object
<p>I'm trying to create json schema for a document where field values in some object should validate against a enum defined in another object in the same document.</p>
<p>More specifically, in the example below, I'd like to be able to define &quot;properties&quot; with <code>id</code> and <code>values</code> (I should be able to define different properties in different json files).
Then &quot;objects&quot; should be able to refer to these properties, so that <code>object.properties[i].id</code> must match with id of one of the properties and <code>object.properties[i].value</code> must match with one of the enum values defined for that property.</p>
<pre><code>{
    &quot;properties&quot;: [
        {
            &quot;id&quot;: &quot;SIZE&quot;,
            &quot;values&quot;: [&quot;small&quot;, &quot;medium&quot;, &quot;big&quot;]
        },
        {
            &quot;id&quot;: &quot;MATERIAL&quot;,
            &quot;values&quot;: [&quot;wood&quot;, &quot;glass&quot;, &quot;steel&quot;, &quot;plastic&quot;]
        },
        {
            &quot;id&quot;: &quot;COLOR&quot;,
            &quot;values&quot;: [&quot;red&quot;, &quot;green&quot;, &quot;blue&quot;]
        }
    ],

    &quot;objects&quot;: [
        {
            &quot;name&quot;: &quot;chair&quot;,
            &quot;properties&quot;: [
                {
                    &quot;id&quot;: &quot;SIZE&quot;,
                    &quot;value&quot;: &quot;small&quot;
                },
                {
                    &quot;id&quot;: &quot;COLOR&quot;,
                    &quot;value&quot;: &quot;red&quot;
                }
            ],
        },
        {
            &quot;name&quot;: &quot;table&quot;,
            &quot;properties&quot;: [
                {
                    &quot;id&quot;: &quot;MATERIAL&quot;,
                    &quot;value&quot;: &quot;wood&quot;
                }
            ]
        }
    ]
}
</code></pre>
<p>I tried to create json schema to validate such structure, but got stuck with describing reference to inner fields of &quot;property&quot; object. I also looked into the <a href="https://datatracker.ietf.org/doc/html/draft-fge-json-schema-validation-00" rel="nofollow noreferrer">standard</a> and did not find a way to achieve the goal.</p>
<p>Is it possible to create a json schema which would validate my json files?</p>