Karate API : How to assert a json/response node value which returns null or an array object for different data

Viewed 536

I've got a request that returns a response node(itemCanBe) value in two possible ways, depending on the 'itemNum'. How do I assert this ? below attempt is not working

* match res..itemCanBe == null || res..itemCanBe[*] contains ['Colgate']

itemCanBe returning null

{
"itemDetails": {
    "1234": {
        "itemNum": "1234",
        "itemCanBe": null
    }
  }
}

itemCanBe returning array

{
"itemDetails": {
    "4567": {
        "itemNum": "4567",
        "itemCanBe": [
            "Colgate",
            "Sensodine"
        ]
    }
}

}

2 Answers
Related