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
unicodeRegExpto theschemacore 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
unicodeRegExpoption is optional, and thus backwards compatible with the existing behavior of spectral'sschemacore function. When the option is omitted, the behavior is defaulted to "false".The
unicodeRegExpoption is also added as an optional flag tooasSchemaandoasExampleoas functions. To preserve the existing behavior of the standard oas ruleset,unicodeRegExp: falsehas been explicitly added to the standardoasruleset'sduplicated-entry-in-enum,oas2-valid-schema-example,oas2-valid-media-example,oas3-valid-media-exampleandoas3-valid-schema-examplerules.Adding this option allows rulesets that use the
schemacore function to opt into using the unicode "u" flag when validating the "pattern" and "patternProperty" fields.Adding this option to
oasExampleandoasSchemaalso allows rulesets that extend fromspectral:oasto replace theoas3-valid-media-exampleandoas3-valid-schema-examplerules with a version that opts into using unicode regular expressions. Doing so is currently a little involved, though, requiring re-specifying thegivenblock of the rules as shown below. But it at least makes the option available to extending rulesets.