# Schema validation ignoring array sub-fields type

**URL:** <https://community.postman.com/t/schema-validation-ignoring-array-sub-fields-type/5200>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [April 29, 2019, 1:19pm UTC](https://community.postman.com/t/schema-validation-ignoring-array-sub-fields-type/5200 "2019-04-29T13:19:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 29, 2019, 1:58pm UTC](https://community.postman.com/t/schema-validation-ignoring-array-sub-fields-type/5200/2 "2019-04-29T13:58:22Z")

</div>

Hey @fermani

Welcome to the community 👋

Not sure what was happening for you locally but the JSON Schema you posted wasn’t valid JSON - It was missing a closing `"` at the end of the `access` key.

I’ve used a different Schema validation module that’s built-in to Postman, to help with this question.

> **[GitHub - ajv-validator/ajv: The fastest JSON schema Validator. Supports JSON...](https://github.com/ajv-validator/ajv)**
>
> The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927) - GitHub - ajv-validator/ajv: The fastest JSON schema Validator. Supports J...

It’s very similar to the `tv4` module but is actively maintained.

I mocked out the response body from the question and this seems to be working (failing the test due to the wrong data type).

```
var Ajv = require('ajv'),
    ajv = new Ajv({logger: console}),
    accessSchema = {
        "properties": {
            "access": { 
                "type": "array",
                "items": {
                    "properties": {
                        "id": { "type": "string" },
                        "client": { "type": "string" },
                        "apikey": { "type": "string" },
                        "description": { "type": "integer" }
                      }
                  }
              }
        }
    }

pm.test('Schema is valid', function() {
    pm.expect(ajv.validate(accessSchema, pm.response.json())).to.be.true;
});  

```

 ![05](https://us1.discourse-cdn.com/getpostman/original/3X/7/7/77bd48b188360fb951631c44ec9b7f3864f6744a.png)

When the schema data types are correct, the test is passing:

 ![17](https://us1.discourse-cdn.com/getpostman/original/2X/b/b9ae886a091a7e32a37be429a0f35ea01e855063.png)

---

_[View the full topic](https://community.postman.com/t/schema-validation-ignoring-array-sub-fields-type/5200)._
