title: Conditional check in JSON schema
body: <p>I have following JSON schema:</p>
  
  <pre><code>{
      "$schema": "http://json-schema.org/draft-04/schema#",
      "type": "object",
      "additionalProperties": false,
      "properties": {
          "Payload": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                  "Person": {
                      "type": "array",
                      "items": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                              "Id": {
                                  "type": "string"
                              },
                              "Name": {
                                  "type": "string"
                              }
                          },
                          "required": [
                              "Id",
                              "Name"
                          ]
                      }
                  }
              }
          },
          "Reference": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                  "Status": {
                      "anyOf": [
                          {
                              "Passed": {
                                  "type": "string"
                              },
                              "Failed": {
                                  "type": "string"
                              }
                          }
                      ]
                  }
              }
          }
      },
      "anyOf": [
          {
              "additionalProperties": false,
              "properties": {
                  "Status": {
                      "type": "string",
                      "enum": [
                          "Failed"
                      ]
                  }
              },
              "required": [
                  "Reference"
              ],
              "not": {
                  "required": [
                      "Payload"
                  ]
              }
          },
          {
              "additionalProperties": true,
              "properties": {
                  "Status": {
                      "type": "string",
                      "enum": [
                          "Passed"
                      ]
                  }
              },
              "required": [
                  "Reference"
              ]
          }
      ]
  }
  </code></pre>
  
  <p>I want to check if JSON message has status failed then person array should not be present.
  It should be present only if status is passed.</p>
  
  <p>I tried following <a href="https://stackoverflow.com/questions/38717933/jsonschema-attribute-conditionally-required">solution here</a> but definitely i am doing something wrong as validator passes with Failed status and person details present. Can someone tell what I may be doing wrong?</p>