Skip to content
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

Can we verify the length of a string using PACT #586

Open
ravichandrasurabhi opened this issue Nov 16, 2017 · 6 comments
Open

Can we verify the length of a string using PACT #586

ravichandrasurabhi opened this issue Nov 16, 2017 · 6 comments
Labels
enhancement Indicates new feature requests

Comments

@ravichandrasurabhi
Copy link

If Yes do we have any example for it.

@uglyog
Copy link
Member

uglyog commented Nov 19, 2017

There is no way to do this, at the moment. Can you provide some insight on what you need to achieve?

@ravichandrasurabhi
Copy link
Author

I need to verify a length of a string. For example there is a ORDER_NUMBER where as per contract should be upto 15 Characters. I want to verify whether in response we are getting less than 15 Chars or not. The max and min values need to be verified. Is it possible through PACT

@MahatmaFatalError
Copy link

what is the conclusion here?

@rholshausen rholshausen added the enhancement Indicates new feature requests label Jan 28, 2024
@rholshausen
Copy link
Contributor

This is currently unsupported

@timvahlbrock
Copy link
Contributor

timvahlbrock commented Jan 7, 2025

I tried achieving something like this first using a string matcher with .{minValue,maxValue} and then using [\s\S]{minValue,maxValue} as . doens't match all unicode chars. However, it seems like this doesn't work either, because many UTF-16 characters are counted as one char in regex, but as two chars in Java, because they consist of two code points instead of one. To support non-ASCII character's this probably needs its own matcher in the Pact specification.

Edit: Also ran into issues like these: #1848

@timvahlbrock
Copy link
Contributor

For context: jakarta validations (which as far as I know is used a lot) provides the @SiZe annotation that enforces that string fields don't exceed a certain length. If we want to prevent that before deployment, we need a way to assert the length of a string field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

6 participants
@MahatmaFatalError @uglyog @timvahlbrock @ravichandrasurabhi @rholshausen and others