json-schema-org / json-schema-org/JSON-Schema-Test-Suite

Regular expression pattern specification and testing clarifications

Open
#898 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
750
Forks
307
Avg merge
3d 17h
Merged PRs (30d)
24

Description

The JSON Schema specifications describes valid regular expression patterns in Section 6.4 by accumulating recommandations:

  • they SHOULD be valid for ECMA-262 with unicode enabled
  • they MUST NOT be assumed as anchored
  • they SHOULD conform to a subset of the regex syntax for portability (schema authors SHOULD limit themselves to the following regular expression tokens), which is:
    • individual Unicode characters eg Caractères accentués…
    • simple and character classes [abc] [a-z]
    • complemented simple character classes [^abc]
    • complemented range character classes [^a-z]
    • repetitions + * ? {x} {x,y} {x,} and their lazy …? counterparts
    • anchors ^ $, grouping (...) and alternation |

Here are some questions:

  1. I understand these SHOULD as a validator is not expected to implement full ECMA-262, but only the prescribed subset, which seems reasonable enough if the spec is expected to be portable across languages. Yes?

  2. The subset description seems a little fuzzy and incomplete. It could be clarified wrt the following points:

    • how are character escaped, or not, in character classes? should it assume POSIX, i.e. no escape with clever positioning? Accept \ on some characters? On all characters? How to include characters ] - ^ \ in a class?
    • can a character class be empty? Can a complemented class be empty? (I would suggest no in both cases).
    • what about wildcard .? I guess it is allowed? if it is allowed, does it reject \n? and \r? or should it assume single-line mode?
    • what about predefined character classes: \s \w \d \D \W \D, are they supported? also inside classes?
    • what about advanced character classes: \p{Letter}, I guess no? If yes, which are expected to be supported?
  3. As far as the test suite is concerned, ISTM that the test suite should be limited to cases covered by the subset, which is currently not the case (it uses . and \{Letter}).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading JSON Schema Core Section 6.4 and reviewing the regular-expression cases in the current test suite. Compare the stated subset with the questions about escaping, character classes, wildcards, and predefined classes, then document an agreed interpretation and update the affected tests so they only assert behavior covered by that interpretation.

Written by the indexing model from the issue text.

Assessment

Domain
documentation, testing
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.