title: Nesting oneOf in anyOf for a JSON Schema
body: <p>Here is the JSON Schema and the JSON as provided below in the link for illustartion purpose.</p>
  
  <p><a href="https://jsonschema.dev/s/N4IgziBcLAOgdrALrESCeAHApqyACVAewCMArbAYxRABoFlVMAnInZpAS2zD3zkQoaYJAEMkAfQAm40XwGMhqDDj6pRzZqPSp6gxagC2neAEkk2Q7yj4AjHoM1OFq-IZKlaLLhvFyVGgcPRhAWNmwObmsCYABfIMd1eHQAeQAzPgBtBWDgkGZsAEcAV04CqSzUAoBzTiJEEABdBNyQsPYuHjd9Vs8auoaY90TWkGx4YsNKkFFDCM5KOSbh3uR4lZGQyiJi+CRmHRsczbyVHwJUEWYTatQN3vWek6Y2YoAbcQHu59PvNXB9jc7k8HvdHLEwUJHidjqsQPVsOlKiCRrCflUiqVytN+vVUM1IZtQqwOlFvqtRrjBvxCRTUONJtNRGBOEtGrSRtC6Xltrt9ochijuco-r4Add4LcQBzclz0Z4pNgxJw3tEaUL0V5VGLSBRqLoZUT2hFOmq0cLPB9JcVRNVzur5c8tfbLoDJcDHbKWp6QkgAF7kn2-bUXcVA6Ua7kQyMnaNBuMWhM-eIOi0YkplbAVGyZDG1PFNb104nhSJdI6GvJUwNpmgMqY5+nFEk+dkxr2VgwgXl7A41n3O-5XcOdqFFzVW6o2u39tODsXD90R+OjpMUtcjNuxyFbjxrhPR2J0ECcKAwYYA8TSWRZAT4e-3vNfMWzeaLA0o7s7XsCwggACqADKACCH4Pg+rriOWoYAKwAAwemOqZdtWL4sksejgY+X58n2YoAFKiJgogNJhWGoIqyqqngd5Ydhk7TucqCEcR8A8D4ZF0coAZisUSCUAA1AAnAAdHBCERnR+6cchfTYPm1JNi2YHkThP7-GkJhWtmMn0SRU62kxIAAGImPAnBgAAFohazuG2R6xEAA" rel="nofollow noreferrer">JSON Schema and the JSON</a></p>
  
  <p>Format:
  The Individual JSON object (with their additional attributes and may vary with other object in the array) within array can be of any 3 region: 'america', 'asia' and 'europe' and at-least on the type of region object should be there. This can be achieved by array minItems property)</p>
  
  <p>Problem Statement:</p>
  
  <ol>
  <li><p>The Individual JSON object within array can be of any 3 region: 'america', 'asia' and 'europe' and at-least on the type of region object should be there </p>
  
  <p>==> I am able to solve this by putting all the region objects in the anyOf array as I want to match at-least one of the valid region object.</p></li>
  <li><p>Either the JSON object 'asia' or 'europe' can exist along with other region type. Both cannot coexist. </p>
  
  <p>==> I tried to use 'oneOf' but its passing the ajv validation. Actually it should fail. Can anyone help. Thanks</p></li>
  </ol>
  
  <p>JSON Schema</p>
  
  <pre><code>{
      "type": "object",
      "properties": {
          "stat_data": {
              "type": "array",
              "minItems": 1,
              "items": {
                  "type": "object",
                  "properties": {},
                  "anyOf": [{
                          "required": ["region"],
                          "properties": {
                              "region": {
                                  "enum": ["america"]
                              },
                              "country": {
                                  "type": "string"
                              },
                              "population": {
                                  "type": "string"
                              }
                          }
                      },
                      {
                          "oneOf": [
                              {
                                  "required": ["region"],
                                  "properties": {
                                      "region": {
                                          "enum": ["asia"]
                                      },
                                      "country": {
                                          "type": "string"
                                      },
                                      "details": {
                                          "type": "object",
                                          "properties": {
                                              "language": {
                                                  "type": "string"
                                              },
                                              "tz": {
                                                  "type": "string"
                                              }
                                          }
                                      }
                                  }
                              }, {
                                  "required": ["region"],
                                  "properties": {
                                      "region": {
                                          "enum": ["europe"]
                                      },
                                      "country": {
                                          "type": "string"
                                      },
                                      "language": {
                                          "type": "string"
                                      }
                                  }
                              }
                          ]
                      }
                  ]
              }
          }
      }
  }
  </code></pre>
  
  <p>JSON Object to FAIL as both "asia" and "europe" type object cannot co-exist.</p>
  
  <pre><code>{
      "stat_data": [{
              "region": "america",
              "country": "USA",
              "states": "50"
          }, {
              "region": "asia",
              "country": "Japan",
              "details": {
                  "language": "Japanese",
                  "tz": "utc+9.00"
              }
          }, {
              "region": "europe",
              "country": "finland",
              "language": "Finnish"
          }
      ]
  }
  </code></pre>
  
  <p>JSON Object to PASS as ONLY "asia" type object exist.</p>
  
  <pre><code>{
      "stat_data": [{
              "region": "america",
              "country": "USA",
              "states": "50"
          }, {
              "region": "asia",
              "country": "Japan",
              "details": {
                  "language": "Japanese",
                  "tz": "utc+9.00"
              }
          }
      ]
  }
  </code></pre>
  
  <p>JSON Object to PASS as ONLY "europe" type object exist.</p>
  
  <pre><code>{
      "stat_data": [{
              "region": "america",
              "country": "USA",
              "states": "50"
          }, {
              "region": "europe",
              "country": "finland",
              "language": "Finnish"
          }
      ]
  }
  </code></pre>