What would be the proper way to create the match string in the case below?
I am stuck with the correct match string which would validate both of the below JSON(s).
In one of them, we have the "Periods" data,
{
"id": 1,
"period":
[
{
"startDate": "2022-05-05",
"endDate": "2022-05-06"
},
{
"startDate": "2022-06-05",
"endDate": "2022-06-06"
}
]
}
on the other its a null array.
{
"id": 1,
"period": []
}
I have been trying with the below match string but the same seems to fail
* match response contains deep "##({period: [{startDate: '#notnull'}]})"
CodePudding user response:
Here you go:
* def dateSchema = { startDate: '#string', endDate: '#string' }
* match response == { id: '#number', period: '#[] dateSchema' }