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
{{ message }}
Repository navigation
Inconsistent and incomplete ECMA-to-PCRE pattern replacements in createPregMatchPattern #917
createPregMatchPattern appears in six constraint files across Draft 6, 7, and 2019-09, but the active replacements are inconsistent between files and several ECMA regex shorthand replacements are commented out without explanation.
The replacements active in each class differ, and several are left commented out:
Replacement
PatternConstraint (all drafts)
PatternPropertiesConstraint (all drafts)
AdditionalPropertiesConstraint (all drafts)
\D → [^0-9]
active
commented out
commented out
\d → [0-9]
active
active
commented out
\p{digit} → ...
→ [0-9]
→ [0-9]
→ \p{Nd} (inconsistent)
\w → [A-Za-z0-9_]
active
commented out
commented out
\W → [^A-Za-z0-9_]
active
commented out
commented out
\s → [\s\x{200B}]
active
commented out
commented out
\p{Letter} → \p{L}
active
active
active
PatternConstraint (which validates string values against a pattern keyword) has all replacements active. The PatternPropertiesConstraint and AdditionalPropertiesConstraint versions (which match property key names against patterns) are missing most of them, with no explanation for why they should differ.
There is also a concrete inconsistency: \p{digit} maps to \p{Nd} in AdditionalPropertiesConstraint but to [0-9] in PatternPropertiesConstraint and PatternConstraint.
Expected Behaviour
A decision should be made on whether the commented-out replacements should be enabled or permanently removed.
If there is a deliberate reason for PatternPropertiesConstraint / AdditionalPropertiesConstraint to use a different (reduced) set of replacements compared to PatternConstraint, that reason should be documented.
The \p{digit} mapping should be consistent across all files.
Commented-out code should not remain in the codebase without explanation.
Activity