Skip to content

Conversation

@jackchuka
Copy link
Owner

This pull request introduces a new count feature to the schema structure, enabling schema authors to specify minimum and maximum occurrences for sections or headings in Markdown documents. The implementation includes schema changes, validation logic, documentation updates, and new integration tests. This provides much more flexibility for validating documents with repeated or optional sections (like step-by-step guides).

Schema and Validation Enhancements:

  • Added a count field (with min and max constraints) to the StructureElement in the schema, allowing sections to be matched multiple times and validated independently. [1] [2] [3] [4] [5]
  • Updated the JSON schema generator and documentation to include the new count constraint. [1] [2] [3]

Validation Logic and Engine Updates:

  • Enhanced the structure validation rule to enforce count constraints, including checking for too few or too many matches and ensuring content rules apply to each match. [1] [2] [3]
  • Updated the tree-building logic to support multi-match elements, correctly binding multiple nodes for repeated sections and tracking match counts and indices. [1] [2] [3] [4] [5] [6]

Documentation and Example Updates:

  • Updated the README.md and example schema/tutorials to demonstrate and explain the new count feature for repeated sections, replacing previous workarounds. [1] [2] [3] [4]

Testing:

  • Added comprehensive integration tests to verify correct enforcement of count constraints, including tests for valid, too few, too many, and content-rule violations within repeated sections.

@jackchuka jackchuka marked this pull request as ready for review January 31, 2026 06:00
@jackchuka jackchuka merged commit 5627981 into main Jan 31, 2026
1 check passed
@jackchuka jackchuka deleted the feat/rule/count-constraint branch January 31, 2026 06:00
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