# Checking Json schema with Ajv, returning invalid schema error

**URL:** <https://community.postman.com/t/checking-json-schema-with-ajv-returning-invalid-schema-error/29762>\
**Category:** Help Hub\
**Created:** [November 16, 2021, 8:14am UTC](https://community.postman.com/t/checking-json-schema-with-ajv-returning-invalid-schema-error/29762 "2021-11-16T08:14:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssryantest](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@ssryantest](https://community.postman.com/u/ssryantest)\
**Post date:** [November 16, 2021, 8:14am UTC](https://community.postman.com/t/checking-json-schema-with-ajv-returning-invalid-schema-error/29762/1 "2021-11-16T08:14:21Z")

</div>

This is the sample json schema  
{

```
"body": ERROR: NOT FOUND: Valid,

"meta": {

    "status": "success",

    "message": "Valid"
}

```

}

I’m using the following codes and getting the error, can any one help me on this issue

var jsonData = JSON.response;

var Ajv = require(‘ajv’),

```auto
ajv = new Ajv({

    logger: console,

    allErrors: true

}),

schema = {

    "type": "Object",

    "required": [

        "body",

        "meta"

    ],

    "properties": {

        "body": {

            "$body": "#/properties/body",

            "type": "string"

        },

        "meta": {

            "$body": "#/properties/meta",

            "type": "array",

            "status": {

                "$body": "#/properties/meta/status",

                "type": "string",

            },

            "message": {

                "$body": "#/properties/meta/message",

                "type": "string"

            }

        }

    }

}

```

pm.test(‘Schema is valid’, function() {

```auto
pm.expect(ajv.validate(schema, jsonData), JSON.stringify(ajv.errors)).to.be.true;

```

});

Error Message–  
Error: schema is invalid: data.type should be equal to one of the allowed values, data.type should be array, data.type should match some schema in anyOf

Reply
