Skip to content

fixes #1248 validating draft4 schemas#1249

Merged
stevehu merged 3 commits into
masterfrom
issue1248
Jun 9, 2026
Merged

fixes #1248 validating draft4 schemas#1249
stevehu merged 3 commits into
masterfrom
issue1248

Conversation

@stevehu

@stevehu stevehu commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates regex compilation/validation so the GraalJS-backed ECMA-262 regex implementation can choose whether to apply the JavaScript Unicode (u) flag based on the schema dialect (aimed at fixing draft-04/draft-07 regex validation differences).

Changes:

  • Add a schema-context-aware overload to RegularExpressionFactory, and route regex compilation through it.
  • Update the GraalJS regex implementation to build RegExp functions with and without the u flag depending on SpecificationVersion.
  • Add a regression test asserting draft-07 regex-format validation behavior with GraalJS.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/test/java/com/networknt/schema/regex/RegularExpressionTest.java Adds a test for draft-07 format: regex behavior using GraalJS and boolean output validation.
src/main/java/com/networknt/schema/regex/RegularExpressionFactory.java Introduces a default, schema-context-aware overload for obtaining compiled regexes.
src/main/java/com/networknt/schema/regex/RegularExpression.java Routes compilation through the new factory overload, passing SchemaContext.
src/main/java/com/networknt/schema/regex/GraalJSRegularExpressionFactory.java Selects unicode/non-unicode regex compilation based on schema dialect version.
src/main/java/com/networknt/schema/regex/GraalJSRegularExpressionContext.java Builds and caches both unicode and non-unicode RegExp builders.
src/main/java/com/networknt/schema/regex/GraalJSRegularExpression.java Adds a unicode toggle to choose the appropriate builder at compile time.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/test/java/com/networknt/schema/regex/RegularExpressionTest.java
@stevehu

stevehu commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

• Pushed the Copilot follow-up to PR #1249.

Commit: bae63a9 Address regex factory review comments

What changed:

  • json-schema-validator/src/main/java/com/networknt/schema/regex/ECMAScriptRegularExpressionFactory.java:50 now forwards the context-aware overload to its delegate.
  • json-schema-validator/src/main/java/com/networknt/schema/regex/AllowRegularExpressionFactory.java:41 now preserves SchemaContext when delegating after the allow check.
  • json-schema-validator/src/main/java/com/networknt/schema/regex/GraalJSRegularExpressionFactory.java:70 now handles null context consistently with the legacy one-arg path.
  • json-schema-validator/src/test/java/com/networknt/schema/regex/RegularExpressionTest.java:65 now has explicit draft-04 coverage, plus decorator-factory coverage for the schema-context
    forwarding.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment on lines +71 to +75
SpecificationVersion dialect = schemaContext != null
? schemaContext.getDialect().getSpecificationVersion()
: null;
boolean unicode = dialect == null
|| dialect.getOrder() >= SpecificationVersion.DRAFT_2019_09.getOrder();
@stevehu

stevehu commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

• Addressed the new Copilot comment on PR #1249 and pushed it.

Commit: 03dc296 Rename regex specification version variable

Change made:

  • Renamed the misleading local variable dialect to specificationVersion in json-schema-validator/src/main/java/com/networknt/schema/regex/GraalJSRegularExpressionFactory.java:70.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@stevehu stevehu merged commit 4edf203 into master Jun 9, 2026
4 checks passed
@stevehu stevehu deleted the issue1248 branch June 9, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants