Hi all I would like to be able to use regex as pa...
# pact-go
n
Hi all I would like to be able to use regex as part of the
FromProviderState
matcher. This would look like something like this
FromProviderState(expr, example, regex)
. This would allow me to enforce a tighter rule on the format of that field, which could be useful because I have no guarantees that the the value returned from provider state complies with the format the consumer is expecting. I cannot implement a custom matcher because the
Matcher
interface (in
matchers/matcher.go
) has a private method
isMatcher
-- preventing implementations outside of the
matchers
package. Is anyone aware of an alternative ? Is it worth creating a issue to convert the
isMatcher
into a public method ?
m
It’s private because you can’t just add new user-defined matchers
n
Thanks @Matt (pactflow.io / pact-js / pact-go) Any idea how I could validate the attribute matches the regex? Short of building that validation on the state handler -- I don't like this approach because it wouldn't be reflected on the contract.
m
I don’t believe you can put a regex matcher in there, it can only check the type of the value provider
i.e. it’s a
Like
matcher
n
Thank you Matt
👍 1