title: JSON Schema - complex validation within array
body: <p>I have an array. This can contain several testObjects. </p>
  
  <pre><code>"testObject": {
    "$id": "#/properties/items/testObject",
    "type": "array",
    "minItems": 1,
    "items": {
      "$id": "#/properties/testObject/items",
      "type": "object",
      "required": [
        "id",
        "testObjectType",
        "title"
      ],
      "properties": {
        "id": {
          "$id": "#/items/id",
          "type": "integer"
        },
        "testObjectType": {
          "$id": "#/items/testObjectType",
          "type": "string"
        },
        "title": {
          "$id": "#/items/title",
          "type": "string"
        }
       }
     }
  </code></pre>
  
  <p>Let's say I wanna ensure, that depending on the testObjectType, another title is allowed. </p>
  
  <pre><code>"allOf": [
   {
     {
    "if": {
      "properties": {
        "testObject": {
          "properties": {
            "testObjectType": {
              "const": "typ1"
            }
          }
        }
      }
    },
    "then": {
      "properties": {
        "testObject": {
          "properties": {
            "title": {
              "const": "testTitle 1"
            }
          }
        }
   }
  ]
  </code></pre>
  
  <p>E.g. if I would do it that way, I can only validate a specific item. But if testObject is an array in another object, I need to have this validation for each items. </p>
  
  <p>To make it more concrete. This is the input: </p>
  
  <pre><code>    {
    "root-element": [
      {
        "id": 1,
        "testObjectType": "testObject 1",
        "title": "title 1"
      },
      {
        "id": 2,
        "testObjectType": "testObject 2",
        "title": "title 2"
      },
      {
        "id": 3,
        "testObjectType": "testObject 3",
        "title": "title 3",
        "anotherAttribute": "anotherValue"
      }
    ]
  }
  </code></pre>
  
  <p>In case testObjectType is "testObject 3", I want to ensure anotherAttribute is also there. </p>
  
  <p>Second validation for "testObject 2", title must be "title 2". 
  I see the problem, that all those objects are within an array and do not know how to validate each element</p>