I want to validate r (Language, Year of Experience, House Number, City, Country, Mobile, Current Address) these field from the Json code. But I am getting error

{
“status”: “true”,
“data”: {
“first_name”: “Kallol”,
“middle_name”: “Sarker”,
“last_name”: “Ananda”,
“date_of_birth”: “14/09/1997”,
“TechnicalDetails”: [
{
“id”: 90154,
“language”: [
“Bangla”,
“English”
],
“yearexp”: “Two years”,
“lastused”: “Before After”,
“st_id”: “4180051”
}
],
“Address”: [
{
“Permanent_Address”: {
“House_Number”: “40/4”,
“City”: “Dhaka”,
“State”: “Dhaka”,
“Country”: “Bangladesh”,
“PhoneNumber”: [
{
“Std_Code”: “1162090”,
“Home”: “Tower Twenty Four”,
“Mobile”: “+8801746684953”
},
{
“Std_Code”: “1110338426”,
“Home”: “Tower twenty four”,
“Mobile”: “+8801913903626”
}
]
},
“Current_Address”: null,
“stId”: “4180051”
},
{
“Permanent_Address”: {
“House_Number”: “40/4”,
“City”: “Dhaka”,
“State”: “Dhaka”,
“Country”: “Bangladesh”,
“PhoneNumber”: [
{
“Std_Code”: “1162090”,
“Home”: “Tower Twenty Four”,
“Mobile”: “+8801746684953”
},
{
“Std_Code”: “1110338426”,
“Home”: “Tower twenty four”,
“Mobile”: “+8801913903626”
}
]
},
“Current_Address”: null,
“stId”: “4180051”
},
{
“Permanent_Address”: {
“House_Number”: “40/4”,
“City”: “Dhaka”,
“State”: “Dhaka”,
“Country”: “Bangladesh”,
“PhoneNumber”: [
{
“Std_Code”: “1162090”,
“Home”: “Tower Twenty Four”,
“Mobile”: “+8801746684953”
},
{
“Std_Code”: “1110338426”,
“Home”: “Tower twenty four”,
“Mobile”: “+8801913903626”
}
]
},
“Current_Address”: null,
“stId”: “4180051”
},
{
“Permanent_Address”: {
“House_Number”: “40/4”,
“City”: “Dhaka”,
“State”: “Dhaka”,
“Country”: “Bangladesh”,
“PhoneNumber”: [
{
“Std_Code”: “1162090”,
“Home”: “Tower Twenty Four”,
“Mobile”: “+8801746684953”
},
{
“Std_Code”: “1110338426”,
“Home”: “Tower twenty four”,
“Mobile”: “+8801913903626”
}
]
},
“Current_Address”: null,
“stId”: “4180051”
}
]
}
}

Didn’t I answer this yesterday?

I want to validate these field but I am getting error - Help - Postman

Your language field validation is failing with undefined, as you are not targeting the array element properly.

It needs to be the following.

pm.test("Language field value validation", function () {
    pm.expect(jsonData.data.TechnicalDetails[0].language).to.eql(["Bangla", "English"]);
});

Same principle for the other assertions.

1 Like