check if query param exists or not

80 views
Skip to first unread message

Ajay Antony

unread,
Apr 16, 2022, 6:11:28 PM4/16/22
to mountebank-discuss
How to add a predicate to check whether a query parameter called "orderId" exists  or not. Is it possible to add regex to check whether its a 10 digit number?

Bob Ruub

unread,
Apr 20, 2022, 9:39:03 PM4/20/22
to mountebank-discuss
The query keyword can check parameters, good example here http://www.mbtest.org/docs/api/predicates, look in the matching array section.

you can try the matches keyword which supports regex syntax. this would match on /v1/stats/1234567.
"predicates":
      [
            {
                        "matches": { "path": "/v1/stats/\\d{7}$" },
                        "caseSensitive": true
            }
        ]
    }

Reply all
Reply to author
Forward
0 new messages