title: conditionally validate a json schema based on a parent property or parent schema
body: <p>I have the following json schema</p>
  <pre><code>{
    &quot;$schema&quot;: &quot;http://json-schema.org/draft-07/schema#&quot;,
    &quot;type&quot;: &quot;object&quot;,
    &quot;title&quot;: &quot;MySchema&quot;,
    &quot;required&quot;: [&quot;environment&quot;, &quot;datacenter&quot;],
    &quot;properties&quot;: {
      &quot;environment&quot;: {
        &quot;type&quot;: &quot;string&quot;,
        &quot;title&quot;: &quot;environment&quot;,
        &quot;enum&quot;: [&quot;DEV&quot;, &quot;STG&quot;, &quot;PROD&quot;]
      },
      &quot;datacenter&quot;: {
        &quot;type&quot;: &quot;object&quot;,
        &quot;title&quot;: &quot;datacenter&quot;,
        &quot;properties&quot;: {
          &quot;value&quot;: {
            &quot;$ref&quot;: &quot;#/definitions/datacenter&quot;
          }
        }
      }
    },
    &quot;definitions&quot;: {
      &quot;datacenter&quot;: {
        &quot;type&quot;: &quot;string&quot;,
        &quot;enum&quot;: [ &quot;devDC1&quot;, &quot;devDC2&quot;, &quot;stgDC1&quot;, &quot;stgDC2&quot;, &quot;prodDC1&quot;, &quot;prodDC2&quot; ]
      }
    }
  }
  </code></pre>
  <p>and here is how it could be simply used</p>
  <pre><code>{
      &quot;$schema&quot;: &quot;http://localhost/schemas/v3/env.json&quot;,
      &quot;environment&quot;: &quot;DEV&quot;,
      &quot;datacenter&quot;: {
          &quot;value&quot;: &quot;devDC1&quot;
      }
  }
  </code></pre>
  <p>what I'm trying to do is something like</p>
  <p>if the environment is set to DEV, then I should only be able to select devDC1, devDC2 for the value of the datacenter attribute, and same if i select STG for environment then stgDC1, stgDC2 are allowed, and same for PROD</p>
  <p>note that
  <code>&quot;$ref&quot;: &quot;#/definitions/datacenter&quot;</code> in my schema is actually referencing another file</p>