Repository navigation
test(regex): accept common valid patterns - #1214
Merged
jdesrosiers merged 1 commit intoOct 11, 2026
Merged
jdesrosiers merged 1 commit into
jdesrosiers merged 1 commit into
Conversation
regex.json accepted only one valid string, "([abc])+\s+$", so a checker that rejected ordinary syntax still passed every case. Add the empty pattern, alternation, a range quantifier, a non-greedy quantifier and a complemented range class. All but the empty pattern come from the portable regex subset in the core specification, and each is accepted by V8 with no flag, with u and with v, and by Python re, Ruby, Perl and Java. Lookarounds and backreferences are left out because RE2-based engines reject them. Closes json-schema-org#1213
jdesrosiers
approved these changes
Oct 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1213.
After #1210,
regex.jsonhad six invalid patterns but only one valid string,([abc])+\s+$. A checker that rejected ordinary syntax could still pass the whole file. This adds valid cases:""a|ba{2,3}a+?[^a-z]Why these five
All but
""come from the portable subset the core spec asks schema authors to limit themselves to (the list discussed in #898). Each one compiles in V8 with no flag, withuand withv, and in Pythonre, Ruby, Perl and Java'sPattern. python-jsonschema, jsonschema-rs and fastjsonschema accept all five as well.Left out because an engine rejects them: lookarounds and backreferences (RE2-based engines),
\p{Lu}(Pythonre),a{65536}(Perl) and[a-](V8 withv).Scope
draft3, draft7, draft2019-09, draft2020-12 and v1, the five drafts that have
regex.json. The copies are identical apart from theschemaobject.Verification
bin/jsonschema_suite checkpasses 11/11 with no skips (jsonschema==4.19.0).Run against the edited draft2020-12 file (18 cases, 12 in draft3):
"",|,{,+?and[^regex(re.compile)new RegExp(s, "u")No engine I tried fails any added case, so like #1210 this is regression coverage, not a fix for a known-failing implementation. No open PR touches
regex.json.