title: How to use dependentRequired with relative reference in JSON schema
body: <p>I have below JSON schema in my app, and i am using <code>NewtonSoft JSON schema validation</code> library to validate user JSON against my schema.</p>
  <p>The rules that i need to set are -</p>
  <ol>
  <li>if user sets <code>property2</code> in the JSON then <code>property3</code> should also exist and <code>subProperty2</code> should also exist underneath <code>property3</code>.</li>
  <li>if user does not set <code>property2</code> then <code>property3</code> is not required.</li>
  </ol>
  <p>I used <code>dependentRequired</code> for this with relative reference using <code>period(.)</code> but that did not work with <code>NewtonSoft</code> package. I tried in 2 different ways, both without expected result.</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;type&quot;: &quot;object&quot;,
    &quot;additionalProperties&quot;: false,
    &quot;properties&quot;: {
      &quot;property1&quot;: {
        ...
      },
      &quot;property2&quot;: {
        ...
      },
      &quot;property3&quot;: {
        &quot;type&quot;: &quot;object&quot;,
        &quot;additionalProperties&quot;: false,
        &quot;properties&quot;: {
          &quot;subProperty1&quot;: {
            ...
          },
          &quot;subProperty2&quot;: {
            ...
          },
        }
      }
    },
     &quot;required&quot;: [
      &quot;property1&quot;
    ]
  }
  </code></pre>
  <p>//try 1</p>
  <pre class="lang-json prettyprint-override"><code>  &quot;dependentRequired&quot;: {
      &quot;property2&quot;: [ &quot;property3.subProperty2&quot; ]
    },
  </code></pre>
  <p>//try 2</p>
  <pre class="lang-json prettyprint-override"><code>  &quot;dependentRequired&quot;: {
      &quot;property2&quot;: {
        &quot;required&quot;: [ &quot;property3&quot; ],
        &quot;property3&quot;: {
          &quot;required&quot;: [ &quot;subProperty2&quot; ]
        }
      }
    } 
  </code></pre>
  <p>Can someone help me with this?</p>