jsonSchema attribute conditionally required
<p>In jsonSchema you can indicate whether defined fields are mandatory or not using the &quot;required&quot; attribute:</p>
<pre><code>{
    &quot;$schema&quot;: &quot;http://json-schema.org/draft-04/schema#&quot;,
    &quot;type&quot;: &quot;object&quot;,
    &quot;properties&quot;: {
        &quot;header&quot;: {
            &quot;type&quot;: &quot;object&quot;,
            &quot;properties&quot;: {
                &quot;messageName&quot;: {
                    &quot;type&quot;: &quot;string&quot;
                },
                &quot;messageVersion&quot;: {
                    &quot;type&quot;: &quot;string&quot;
                }
            },
            &quot;required&quot;: [
                &quot;messageName&quot;,
                &quot;messageVersion&quot;
            ]
        }
    },
    &quot;required&quot;: [
        &quot;header&quot;
    ]
}
</code></pre>
<p>In certain cases, I would like the <em>messageVersion</em> field not to be mandatory. Is there any way to make the mandatory-ness of the this field conditional?</p>