feat(functions): add unicodeRegExp option to schema core function #2809
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.
Fixes #2419.
Checklist
Does this PR introduce a breaking change?
Screenshots
Before:
After:
Added unicodeRegExp to core function docs

Additional context
Adds an option
unicodeRegExp
to theschema
core function. Defaults to "false". When "true", uses the unicode flag "u" with "pattern" and "patternProperties" fields during schema validation; otherwise does not use the "u" flag when "false" or omitted.The
unicodeRegExp
option is optional, and thus backwards compatible with the existing behavior of spectral'sschema
core function. When the option is omitted, the behavior is defaulted to "false".The
unicodeRegExp
option is also added as an optional flag tooasSchema
andoasExample
oas functions. To preserve the existing behavior of the standard oas ruleset,unicodeRegExp: false
has been explicitly added to the standardoas
ruleset'sduplicated-entry-in-enum
,oas2-valid-schema-example
,oas2-valid-media-example
,oas3-valid-media-example
andoas3-valid-schema-example
rules.Adding this option allows rulesets that use the
schema
core function to opt into using the unicode "u" flag when validating the "pattern" and "patternProperty" fields.Adding this option to
oasExample
andoasSchema
also allows rulesets that extend fromspectral:oas
to replace theoas3-valid-media-example
andoas3-valid-schema-example
rules with a version that opts into using unicode regular expressions. Doing so is currently a little involved, though, requiring re-specifying thegiven
block of the rules as shown below. But it at least makes the option available to extending rulesets.