I am trying to validate a particular json field amount
in the request to have number and not string
{
"request": {
"method": "POST",
"urlPath": "/charges",
"bodyPatterns" : [
{"matchesJsonPath" : "$[?(@.amount =~ /^[0-9]*$/i)]"}
]
}
Now request1 and request2 are working fine and request3 fails. But I expect request2 to fail as well because it is a string and not number as it is in double quotes.
Request 1,
{
"amount": 123,
}
Request 2,
{
"amount": "123",
}
Request 3,
{
"amount": "a123",
}
Is this possible?. I see in wiremock docs
Since WireMock’s matching operators all work on strings,
the value selected by the JSONPath expression will be coerced to a string before the match is evaluated.