response= [
{
"id": "123",
"name: "user1",
"location": "USA"
},
{
"id": "133",
"name: "user2",
"location": "CANADA"
},
{
"id": "",
"name": "user3",
"location": "INDIA"
}
]
I am trying to validate the above json array using the schema and want to validate that values of my keys should not be empty or blank.
I am using the below code:
* def schema = {"id": "#notnull", "name": "#notnull", "location": "#notnull"}
* match each response contains schema
But even though my response has "id":"" -- id is empty/blank in the 3rd index in json array. Still I get a pass in my scenario. Is this the correct way or is there any other way to handle empty values in schema for a json array response.
Your help would be appreciated. Thank you
Ideally we should have #notblank
but we don't because it is so rare.
Do this instead:
* match each response contains { id: "#? _ != ''" }