Skip to content

Fix patternProperties validation to apply to all properties#1898

Merged
lahma merged 1 commit into
RicoSuter:masterfrom
lahma:fix/1736-pattern-properties-validation
Mar 7, 2026
Merged

Fix patternProperties validation to apply to all properties#1898
lahma merged 1 commit into
RicoSuter:masterfrom
lahma:fix/1736-pattern-properties-validation

Conversation

@lahma

@lahma lahma commented Mar 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • patternProperties validation was only applied to additional properties (not in the schema's properties collection), but the JSON Schema spec requires it to be evaluated against all object properties
  • Changed ValidatePatternProperties to receive all properties for validation, while still correctly removing matched properties from the additional properties list for additionalProperties evaluation

Test plan

  • 4 new tests added to PatternPropertyValidationTests.cs:
    • Defined property value doesn't match pattern → validation fails
    • Defined property value matches pattern → validation succeeds
    • Mixed defined + additional properties with pattern → works correctly
    • Defined property name doesn't match pattern regex → pattern not applied
  • All 3 existing pattern property tests still pass
  • All 452 tests pass with no regressions

Fixes #1736

🤖 Generated with Claude Code

patternProperties was only validated against additional properties (those
not in the schema's properties collection). Per JSON Schema spec,
patternProperties should be evaluated against all object properties.

Fixes RicoSuter#1736

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lahma lahma requested a review from RicoSuter March 7, 2026 13:17
@lahma lahma merged commit 2d9d656 into RicoSuter:master Mar 7, 2026
2 checks passed
This was referenced Apr 8, 2026
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.

ValidatePatternProperties applied only to additionalProperties

1 participant