【发布时间】:2020-12-26 20:36:12
【问题描述】:
我正在尝试验证请求中的特定 json 字段 amount 是否包含数字而不是字符串
{
"request": {
"method": "POST",
"urlPath": "/charges",
"bodyPatterns" : [
{"matchesJsonPath" : "$[?(@.amount =~ /^[0-9]*$/i)]"}
]
}
现在 request1 和 request2 工作正常, request3 失败。但我希望 request2 也会失败,因为它是一个字符串,而不是双引号中的数字。
请求 1,
{
"amount": 123,
}
请求 2,
{
"amount": "123",
}
请求 3,
{
"amount": "a123",
}
这可能吗?我在 wiremock 文档中看到
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.
【问题讨论】:
标签: wiremock wiremock-standalone