json-schema-org / json-schema-spec

The JSON Schema specification

Home Page:http://json-schema.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pattern: clarification on whether leading and trailing delimiters are allowed or required

spacether opened this issue · comments

So the definition of pattern is:

 6.3.3. pattern

The value of this keyword MUST be a string. This string SHOULD be a valid regular expression, according to the ECMA-262 regular expression dialect.
A string instance is considered valid if the regular expression matches the instance successfully. Recall: regular expressions are not implicitly anchored.

Does that include the regex literal delimiter / which means that pattern values must look like /pattern/flags (ECMA-262 15.10 or 7.85) or does it just include the pattern (ECMA-262 15.10.1)?
The spec is unclear because it does not link to a specific section of ECMA-262
Can this be clarified? What is allowed? What is required?

Section 6.4 which is the "global" section on regular expressions does point to ECMA 262 Section 21.2.1 which is a section on just the pattern with no flags, so to my quick reading that seems like the answer is "the spec already says it's just the pattern", but adding a crosslink (from pattern to 6.4, and the same for patternProperties, which reminds the reader of what regular expression in the 262 dialect specifically means) seems like it couldn't hurt.

Yes, if we could add a link or specify that 262 section 21.2.1 applies in the pattern section in the validation portion of the spec, that would meet my needs.