# Schema Validation failure

**URL:** <https://community.postman.com/t/schema-validation-failure/17018>\
**Category:** Help Hub\
**Tags:** schemavalidation\
**Created:** [October 23, 2020, 1:49am UTC](https://community.postman.com/t/schema-validation-failure/17018 "2020-10-23T01:49:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anumundada](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Anumundada](https://community.postman.com/u/Anumundada)\
**Post date:** [October 23, 2020, 1:49am UTC](https://community.postman.com/t/schema-validation-failure/17018/1 "2020-10-23T01:49:49Z")

</div>

I am getting Assertion error when I run the tv4 or Ajv validators —

**AssertionError:** [  
{“keyword”:“type”,“dataPath”:".SystemVariables[18].Value",“schemaPath”:"#/properties/SystemVariables/items/anyOf/0/properties/Value/type",“params”:{“type”:“string”},“message”:“should be string”},  
{“keyword”:“type”,“dataPath”:".SystemVariables[18].DefaultValue",“schemaPath”:"#/properties/SystemVariables/items/anyOf/0/properties/DefaultValue/type",“params”:{“type”:“string”},“message”:“should be string”},  
{“keyword”:“anyOf”,“dataPath”:".SystemVariables[18]",“schemaPath”:"#/properties/SystemVariables/items/anyOf",“params”:{},“message”:“should match some schema in anyOf”},

**Code for the AJV**  
var Ajv = require(‘ajv’), ajv = new Ajv({ logger: console, allErrors: true }), schema = {…MASSIVE SCHEMA…}

pm.test(‘Schema is valid from AJV’, function() {  
pm.expect(ajv.validate(schema, pm.response.json()), JSON.stringify(ajv.errors)).to.be.true; });

**Code for the tv4**  
var schema\_valid = {…massive schema…}  
pm.test(“Validate schema”, () =\> {pm.response.to.have.jsonSchema(schema\_valid);});

```
const responseData = pm.response.json()
pm.test("Schema is valid", function(){
let validation = tv4.validate(responseData, schema_valid);
if (validation !== true) {
    console.log(tv4.error);
    }
pm.expect(validation).to.be.true;

```

});

The issue areas mentioned in the Assertion error from the schema(I used a tool to generate schema) –

1. This is the Schema \>\> Schemepath which is being mentioned in the error–

2. This is the datapath from the Schema which is being mentioned in the error

CAn some please throw some light as to what is wrong with the schema

---

<div class="post-metadata">

**Author:** ![odanylewycz](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/odanylewycz/32/3240_2.png) [@odanylewycz](https://community.postman.com/u/odanylewycz)\
**Post date:** [October 23, 2020, 11:31am UTC](https://community.postman.com/t/schema-validation-failure/17018/2 "2020-10-23T11:31:01Z")

</div>

Hi @Anumundada,

Welcome to the community! 👏

While you have provided quite a bit of information, would you be able to add screenshots as well for more context?

Personally, I read through what you wrote, and while it seems exhaustive, I’m not certain where the issue is.

It looks like you have the right type in your schema for the values. However, in your actual, it looks like you have numbers set to those variables, though, they look like “string” numbers and not actual numbers (or integer types for that matter).

With that, it looks like what you have is correct. Screenshots may help get more information to resolve your issue.

Other than that, it’s been awhile since I have done schema validation, so I can’t immediately see anything wrong with what you’ve provided.

Best,  
Orest

---

<div class="post-metadata">

**Author:** ![rituthakur23](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@rituthakur23](https://community.postman.com/u/rituthakur23)\
**Post date:** [June 2, 2023, 4:28pm UTC](https://community.postman.com/t/schema-validation-failure/17018/3 "2023-06-02T16:28:44Z")

</div>

Hi All,  
I am facing this schema validation error for type Schema is valid | AssertionError: [{“keyword”:“type”,“dataPath”:“[0].yield”,“schemaPath”:“#/items/properties/yield/type”,“params”:{“type”:“integer”},“message”:“should be integer”},{“keyword”:“type”,“dataPath”:“[1].yield”,“schemaPath”:“#/items/properties/yield/type”,“params”:{“type”:“integer”},“message”:“should be integer”},{“keyword”:“type”,“dataPath”:“[2].yield”,“schemaPath”:“#/items/properties/yield/type”,“params”:{“type”:“integer”},“message”:“should be integer”},{“keyword”:“type”,“dataPath”:“[3].yield”,“schemaPath”:“#/items/properties/yield/type”,“params”:{“type”:“integer”},“message”:“should be integer”},{“keyword”:“type”,“dataPath”:“[4].yield”,“schemaPath”:“#/items/properties/yield/type”,“params”:{“type”:“integer”},“message”:“should be integer”},{“keyword”:“type”,“dataPath”:“[5].yield”,“schemaPath”:“#/items/properties/yield/type”,“params”:{“type”:“integer”},“message”:“should be integer”},{“keyword”:“type”,“dataPath”:“[6].yield”,“schemaPath”:“#/items/properties/yield/type”,“params”:{“type”:“integer”},“message”:“should be integer”},{“keyword”:“type”,“dataPath”:“[7].yield”,“schemaPath”:“#/items/properties/yield/type”,“params”:{“type”:“integer”},“message”:“should be integer”},{“keyword”:“type”,“dataPath”:“[8].yield”,“schemaPath”:“#/items/properties/yield/type”,“params”:{“type”:“integer”},“message”:“should be integer”},{“keyword”:“type”,“dataPath”:“[9].close”,“schemaPath”:“#/items/properties/close/type”,“params”:{“type”:“number”},“message”:“should be number”},{“keyword”:“type”,“dataPath”:"  
is there any way of ignoring datatypes

my code  
var Ajv = require(‘ajv’),  
ajv = new Ajv({logger: console , allErrors: true}),  
schema = {  
// var schema = {  
“type”: “array”,  
“default”: ,  
“title”: “Root Schema”,  
“items”: {  
“type”: “object”,  
“default”: {},  
“title”: “A Schema”,  
“required”: [  
“symbol”,  
“name”,  
“fund\_family”,  
“category”,  
“asset\_class”,  
“objective”,  
“morningstar\_rating”,  
“is\_index\_fund”,  
“is\_leveraged”,  
“close”,  
“volume”,  
“yield”,  
“divexdate”,  
// “return1Y”,  
“holdings\_region”,  
“expense\_ratio”,  
“holdings”  
],  
“properties”: {  
“symbol”: {  
“type”: “string”,  
“default”: “”,  
“title”: “The symbol Schema”,  
“examples”: [  
“AAA”  
]  
},  
“name”: {  
“type”: “string”,  
“default”: “”,  
“title”: “The name Schema”,  
“examples”: [  
“AXS First Priority CLO Bond ETF”  
]  
},

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [June 5, 2023, 10:30am UTC](https://community.postman.com/t/schema-validation-failure/17018/4 "2023-06-05T10:30:32Z")

</div>

@rituthakur23

I can’t read your code as its all aligned to the left.

Can you please repost using the preformatted text option which will keep the formatting.

Can you also include an example response so we can understand the schema. (Also using the preformatted text option).
