You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Authoring JSON Schemas that utilize regex patterns for properties where we do not want a string to end in a certain character (such as - or _); for this, negative lookbehinds are a highly useful tool.
Describe the proposal
As of today, while JSON Schema supports lookahead regex patterns, it does not appear to support lookbehinds. See:
JSON Schema already defines the regular expression dialect to be defined by ECMA 262 [Reference], which means it already does support lookbehind. 🎉
However, JSON Schema is not just for JavaScript. It's not reasonable to expect implementations in Java, C#, Python, Ruby, etc to perfectly match JavaScript's regex dialect. That's why we suggest (not require) schema authors limit their use of regex features to what is likely to be supported by most regex engines. It would be impractical to expect implementations in non-JavaScript languages to implement ECMA-262 regular expression to comply with the spec. Implementations are going to use the regex engines available to them in the language they're implementing in.
Describe the inspiration for your proposal
Authoring JSON Schemas that utilize regex patterns for properties where we do not want a string to end in a certain character (such as
-
or_
); for this, negative lookbehinds are a highly useful tool.Describe the proposal
As of today, while JSON Schema supports lookahead regex patterns, it does not appear to support lookbehinds. See:
Lookbehind was introduced in ES2018 and now enjoys broad support:
This seems like a natural addition!
Describe alternatives you've considered
No response
Additional context
Previously raised or mentioned in:
The text was updated successfully, but these errors were encountered: