-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Support minLength
and maxLength
for stringMatching
#5562
Comments
So far the only option I have for it is to play with |
Hmm, interesting problem. Regular expressions are closed under intersection. So one idea might be to "just" compute the intersection of One way to do it might be:
Any route involving DFAs seems to come with the danger of exponential blow up. For the regular expressions from formal language theory, this is maybe not too complicated but I can imagine you need a ton of case distinctions for the the full JavaScript regular expressions. So not sure if this is the best approach. |
This certainly sounds quite tricky! Thanks for all the research here :) By the way @dubzzz, in case it changes priority, in addition to needing this for We were trying to automatically generate example values for OpenAPI spec schemas like the following (this is just an example schema): type: string
pattern: [a-z]+
minLength: 3
maxLength: 10 I ended doing It's still very quick, but I only needed to generate one value from |
🚀 Feature Request
stringMatching
generates based on the regular expression, but doesn't provide a way to set a min or max length on the generated strings.Motivation
Sometimes you want to test specific lengths of a string matching a regex, but modifying a regular expression to have a specific min and/or max length can be pretty hard and confusing. It would be a lot easier to just be able to pass
minLength
andmaxLength
like thestring
arbitrary.Example
The text was updated successfully, but these errors were encountered: