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

Please revert fix from #815 (pattern validation) #872

Open
kool79 opened this issue Oct 11, 2023 · 3 comments
Open

Please revert fix from #815 (pattern validation) #872

kool79 opened this issue Oct 11, 2023 · 3 comments

Comments

@kool79
Copy link

kool79 commented Oct 11, 2023

Please revert fix made in scope of #815.
This fix was deployed based on incorrect assumption that java works incorrectly with regexp.
But actually issue is not in java. Issue (reported in #814) was caused by incorrect regexp which author uses us json schema.

STR:
GIVEN:
user (in schema) defines regexp as: ^red|banana$ (starts with 'red' OR ends with 'banana')
to pass any strings like: "red", "banana", "red apple", "green banana", "red oval apple"

But the #815 fix will will change regexp to ^(red|banana)$ which will pass ONLY "red" or "banana"

For more details please see my comment to the code
https://github.com/networknt/json-schema-validator/pull/815/files#diff-776968543c85221a4907857a99fb117ab32872c5f0c020a717c11fe8162ef310R12-R24

@kool79 kool79 changed the title Please revert fix from #815 Please revert fix from #815 (pattern validation) Oct 11, 2023
@kool79
Copy link
Author

kool79 commented Oct 11, 2023

Alternative tool for visualization: https://regexper.com/#%5Ered%7Cbanana%24
scr_2023_10_11T15_39_37
scr_2023_10_11T15_39_56

@stevehu
Copy link
Contributor

stevehu commented Oct 11, 2023

@fdutton What do you think? Thanks.

@Stephan202
Copy link
Contributor

I started looking into this, and the topic is quite a rabbit hole, both in terms of regex matching behavior and invalidate test cases. I tried my best at cleaning things up in #888. @kool79 @fdutton reviews very welcome!

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

No branches or pull requests

3 participants