-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Matcher Request: Matcher that verifies the length of a string #111
Comments
Would you mind elaborating on your use case a little further? Whilst this might be a useful thing at the validation layer when writing to a database, it might be too restrictive in a general use case in Pact. I'm not saying it's wrong, but it does feel like we're enforcing a schema on a provider, which is not really the intent of contract testing. From this article:
|
Hm. I see what you mean. At the current point it would actually affect the consumer, as we're currently asserting that the string wouldn't be too long and will reject the entire message otherwise. This is mainly caused by us still relying on code generated from a schema and probably wouldn't be switching away any time soon to a tolerant reader approach. Another aspect of this is that I wrote a helper construct inspired by something similar like the |
I'm not sure whether a string limitation would make a string unnecessarily brittle, because if the consumer is expecting a string to not be longer than a certain size for storage, display or interpretation reasons, I would think of it as a valid response if the provider provided a string longer than that. However, if the provider does not modify their example value beyond the expected limit when increasing the allowed string length it would be impossible for impact the differences in expectations. |
So what I get from this is that while catching a provider exceeding the limit expected by the consumer would be nice to catch using contract tests, it would only be possible if the provider actively tries to exhaust those string limits when choosing the provided example values. Right? |
Our application uses the jakarata validation's
Size
annotation to limit the length a string can have. I tried representing this using regular expressions, but ran into several issues with how regex's counts characters (each symbol is one char) vs how they are counted in java (how many utf-16 unicode chars are used), see pact-foundation/pact-jvm#586. Maybe this can be solved using a dedicated matcher in the pact specification? It would probably also need to contain information on how the characters are counted, maybe having the options of different charactersets or bytes is sufficient.The text was updated successfully, but these errors were encountered: