# To Validate a field value in a List

**URL:** <https://community.postman.com/t/to-validate-a-field-value-in-a-list/13985>\
**Category:** Help Hub\
**Created:** [July 8, 2020, 12:10pm UTC](https://community.postman.com/t/to-validate-a-field-value-in-a-list/13985 "2020-07-08T12:10:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeycle22](https://avatars.discourse-cdn.com/v4/letter/h/b19c9b/32.png) [@honeycle22](https://community.postman.com/u/honeycle22)\
**Post date:** [July 8, 2020, 12:10pm UTC](https://community.postman.com/t/to-validate-a-field-value-in-a-list/13985/1 "2020-07-08T12:10:43Z")

</div>

[  
{  
“accepted”: true,  
“bot”: {  
“code”: “xxx”,  
“key\_types”: [  
{  
“code”: “xxx”,  
“value”: “xxx”  
}  
]  
},  
“delete\_application\_code”: “xxx”,  
“deleted”: true,  
“deletion\_refusal\_reason”: “”,  
“master\_application\_code”: “xxx”,  
“refusal”: {  
“code”: “1201”,  
“reason”: “xxx-xxx-x-xxx-xxxx”  
}  
},  
{  
“accepted”: true,  
“bot”: {  
“code”: “xxx”,  
“key\_types”: [  
{  
“code”: “xxx”,  
“value”: “xxx”  
}  
]  
},  
“delete\_application\_code”: “xxx”,  
“deleted”: true,  
“deletion\_refusal\_reason”: “”,  
“master\_application\_code”: “xxx”,  
“refusal”: {  
“code”: “1201”,  
“reason”: “xxx-xxx-x-xxx-xxxx”  
}  
},  
{  
“accepted”: true,  
“bot”: {  
“code”: “xxx”,  
“key\_types”: [  
{  
“code”: “xxx”,  
“value”: “xxx”  
}  
]  
},  
“delete\_application\_code”: “xxx”,  
“deleted”: true,  
“deletion\_refusal\_reason”: “”,  
“master\_application\_code”: “xxx”,  
“refusal”: {  
“code”: “1201”,  
“reason”: “xxx-xxx-x-xxx-xxxx”  
}  
}  
]

This is my response Body and here i want to validate the field value in this list " accepted": true"  
Below is the code i wrote:  
var jsonData = pm.response.json();

console.log(typeof jsonData);

var responseSchema={

```
"type": "object",

"title": "accepted",

"description": "This is an Delete Statuses Rest Service",

"required": [

    "accepted"

],

"properties": {

    "bot": {

        "type": "object"

    },

}

```

};

pm.test(“DELETE accepted should be TRUE”,function(){

```
pm.expect(tv4.validate(jsonData, responseSchema)).to.be.true;

```

});

But i see that the assertion is failing with below error even if the value is true for all the fields in the List  
DELETE accepted should be TRUE | AssertionError: expected false to be true

Kindly suggest or correct me if anything is incorrect

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [July 10, 2020, 2:42am UTC](https://community.postman.com/t/to-validate-a-field-value-in-a-list/13985/2 "2020-07-10T02:42:55Z")

</div>

First of all, I don’t recommend using tv4.  
Second of all, your response body is an array but you have written the schema for a single object.

Here is a tutorial to get you started with schema validation in Postman:

[![](https://img.youtube.com/vi/haDQBmQii2g/maxresdefault.jpg "JSON Schema validation in Postman") ](https://www.youtube.com/watch?v=haDQBmQii2g)

After this, your schema should look more like this example (which is similar to your case):

```
const schema = {
    "type": "array",
    "items": { "$ref": "#/definitions/customer" },
    "definitions": {
        "customer": {
            "type": "object",
            "required": ["id", "fistName", "lastName", "title", "gender"],
            "properties": {
                "id": {
                    "type": "number",
                    "description": "internal id"
                },
                "fistName": {
                    "type": "string",
                    "description": "First name"
                },
                "lastName": {
                    "type": "string",
                    "description": "Last name"
                },
                "title": {
                    "type": "string",
                    "description": "Title"
                },
                "gender": {
                    "type": "string",
                    "description": "Gender (male / female)",
                    "enum": ["male", "female"]
                }
            }
        }
    }  
};

pm.test("Validate schema", () => {
    pm.response.to.have.jsonSchema(schema);
});

```
