title: JSON Schema Nested If Then
body: <p>I cannot seem to find a working way of applying multiple if/then logic on an enum.</p>
  
  <p><code>anyOf</code> doesnt apply the conditional logic, but instead it says if any of them match then thats good.</p>
  
  <p><code>allOf</code> again doesnt apply the conditional logic but tests a superset of the properties/required fields.</p>
  
  <p>Here is a JSON Schema example:</p>
  
  <pre><code>{
    "definitions": {},
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "http://example.com/root.json",
    "type": "object",
    "title": "The Root Schema",
    "required": [
      "type"
    ],
    "properties": {
      "type": {
        "$id": "#/properties/type",
        "enum": [
          "a",
          "b",
          "c"
        ],
        "title": "The Type"
      },
      "options": {
        "$id": "#/properties/options",
        "type": "object",
        "title": "The Options Schema",
        "oneOf": [
          {
            "if": { "properties": { "type": { "const": "a" } }
            },
            "then": {
              "required": [ "option1" ],
              "properties": {
                "option1": {
                  "$id": "#/properties/options/properties/option1",
                  "type": "boolean",
                  "title": "The option1 Schema"
                }
              }
            }
          },
          {
            "if": { "properties": { "type": { "const": "b" } }
            },
            "then": {
              "required": [ "option2" ],
              "properties": {
                "option2": {
                  "$id": "#/properties/options/properties/option2",
                  "type": "boolean",
                  "title": "The option2 Schema"
                }
              }
            }
          },
          {
            "if": { "properties": { "type": { "const": "c" } }
            },
            "then": {
              "required": [],
              "properties": {}
            }
          }
        ]
      }
    }
  }
  </code></pre>
  
  <p>If you validate against this JSON:</p>
  
  <pre><code>{
    "type": "a",
    "options": {
      "option1": true
    }
  }
  </code></pre>
  
  <p>It fails because <code>option2</code> is required.</p>
  
  <p>If you change it to <code>anyOf</code> then it succeeds, but if you change the JSON to be invalid:</p>
  
  <pre><code>{
    "type": "a",
    "options": {
      "option2": false
    }
  }
  </code></pre>
  
  <p>It still succeeds.</p>
  
  <p>I havent managed to get nested if/then/else/if/then/else working either.</p>
  
  <p>How can i perform a check where I have set of properties for each <code>type</code> and you cannot intermingle them? Is this actually possible, or should I just change my design.</p>