Hi. I just got a request to add some numeric match...
# wiremock-java
d
Hi. I just got a request to add some numeric matchers within the state extension. I was checking core wiremock and didn't find any implementation that would match it. In the end, the user wanted to achieve something like this:
Copy code
{
  "request": {
    "cookies": {
      "my_profile": {
        "gte": "10"
      }
    }
  }
}
When implementing this in the state extension, I would have inherited from
StringValuePattern
- but unfortunately JsonDeserialization doesn't allow any extension thereof. So: Is there any other alternative to achieve these matchers with built-in functionalities? If not: would it be ok to provide a PR for StringValuePattern (in 4.0.0) to make it more extensible. Or, alternatively, would this (and similar) numeric matchers be a sensible addition to wiremock core and would it be ok if I provide PR to contribute these?
t
I’ve been thinking for a while we should add these, so I’m definitely willing to merge/assist. StringValuePattern is the still the way to go if you’re matching HTTP elements since they’re always strings, but I guess if you’re matching bits of state that are numerically typed then ContentPattern<Number> might be the way to go. Possibly needs a bit of experimentation. I can also see that this would be useful for JSONPath/XPath submatchers, which could also work with non-string typed data.
d
the idea would be to add plain StringValuePatterns. The rest already works, so the integration would be smooth: the bridge to state already works for the existing Patterns. I would go ahead and provide a PR. Version 3 or 4?
👍 1
t
4 - we’re only doing security patching on 3 now
👍 1