> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JSON Schema Validation Application - REST-to-SOAP Type API Proxy

In this scenario, the application of the **JSON Schema Validation** policy to a Mock API created on Apinizer will be tested.

Assuming that the JSON body of incoming requests in the scenario is the same, let's add this to the All section.

<img src="https://mintcdn.com/apinizer/I33iYMzwyLMFhLRP/images/tutorials/json-schema-validation-politika-all-ekleme.png?fit=max&auto=format&n=I33iYMzwyLMFhLRP&q=85&s=769904439afbbc6615fe6cb7965a5e0f" alt="Adding JSON Schema Validation policy to All section" width="1000" data-path="images/tutorials/json-schema-validation-politika-all-ekleme.png" />

We add JSON Schema Validation as a policy.

<img src="https://mintcdn.com/apinizer/I33iYMzwyLMFhLRP/images/tutorials/json-schema-validation-politika-ekleme.png?fit=max&auto=format&n=I33iYMzwyLMFhLRP&q=85&s=ef479f98d3171c73d2f4e92003ed965b" alt="Adding JSON Schema Validation policy" width="1000" data-path="images/tutorials/json-schema-validation-politika-ekleme.png" />

**Example request body in Mock Api will be as follows:**

```json theme={null}
{
  "Sorgula": {
    "kriterListesi": {
      "BilesikKutukSorgulaKimlikNoSorguKriteri": {
        "DogumAy": 5,
        "DogumGun": 21,
        "DogumYil": 1990,
        "KimlikNo": "12345678901"
      }
    }
  }
}
```

**A JSON Schema Validation suitable for this includes the following:**

* **DogumAy**: A value between 1 and 12 can be sent.
* **DogumGun**: A value between 1 and 31 can be sent.
* **DogumYil**: A value between 1800 and 2100 can be sent.
* **KimlikNo**: Must be a string (Identity number) with a length of 11 characters.

**JSON Schema Validation to be added to the policy:**

```json theme={null}
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "Sorgula": {
      "type": "object",
      "properties": {
        "kriterListesi": {
          "type": "object",
          "properties": {
            "BilesikKutukSorgulaKimlikNoSorguKriteri": {
              "type": "object",
              "properties": {
                "DogumAy": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 12
                },
                "DogumGun": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 31
                },
                "DogumYil": {
                  "type": "integer",
                  "minimum": 1800,
                  "maximum": 2100
                },
                "KimlikNo": {
                  "type": "string",
                  "minLength": 11,
                  "maxLength": 11
                }
              },
              "required": ["DogumAy", "DogumGun", "DogumYil", "KimlikNo"]
            }
          },
          "required": ["BilesikKutukSorgulaKimlikNoSorguKriteri"]
        }
      },
      "required": ["kriterListesi"]
    }
  },
  "required": ["Sorgula"]
}
```

The JSON Schema Validation content above is added to the **"Schema"** field in the image below and saved.

<img src="https://mintcdn.com/apinizer/I33iYMzwyLMFhLRP/images/tutorials/json-schema-validation-schema-alani.png?fit=max&auto=format&n=I33iYMzwyLMFhLRP&q=85&s=f8b030be5644de92cf2e5e937af80a93" alt="JSON Schema Validation Schema field" width="1000" data-path="images/tutorials/json-schema-validation-schema-alani.png" />

When we send a request from the test console, **KimlikNo** was entered as 12 characters and validation was performed. We received a warning that it can only be 11 characters long.

<img src="https://mintcdn.com/apinizer/I33iYMzwyLMFhLRP/images/tutorials/json-schema-validation-test-sonucu.png?fit=max&auto=format&n=I33iYMzwyLMFhLRP&q=85&s=368d4e2e3924bd8c003b9912e05fe621" alt="JSON Schema Validation test result" width="1000" data-path="images/tutorials/json-schema-validation-test-sonucu.png" />
