I am trying to validate an API response schema with this structure in Karate:
{
"payoutQuotes": [ //could be empty or not but when not empty must have the required object structure inside
{
"customerDomain": {
"financialAccountData": {
"payoutQuoteId": "#number",
"payoutQuoteExpiryDate": "#? isValidDate(_)",
"totalAmountOfPayoutQuote": "#number",
"payoutQuoteCreateDate": "#? isValidDate(_)",
"payoutRequestedBy": "#string"
}
}
}
]
}
Now if the response returns an empty "payoutQuotes" array then it is acceptable but when it also contains the object(s) inside, I want to check they have the proper required key-value combinations. Please note that I have this schema saved as a separate file in my data folder of the project to be used for my schema validation.