Repository navigation
feat(rule): add items_must_match to list rules - #89
Closed
kinchoKayaba wants to merge 1 commit into
Closed
kinchoKayaba wants to merge 1 commit into
kinchoKayaba wants to merge 1 commit into
Conversation
Section rules could require a list but not constrain what its items
say, so a convention such as "each item is a single identifier" had
no enforceable form.
- parse each list's direct items, keeping the item's raw Markdown
source (inline markup such as **bold** is preserved) and marking
sub-lists as nested
- add `items_must_match` to list rules, reusing required_text's
"text" (substring) / {pattern: ...} (regex) entry forms; every
top-level item of a list matching `type` must satisfy every entry,
with one violation per failing (item, entry) at the item's position
- nested sub-list items are not checked
- document the option and describe it in generated templates
Co-Authored-By: Claude Opus 5.5 <[email protected]>
kinchoKayaba
force-pushed
the
feature/list-items-must-match
branch
from
September 30, 2026 03:59
b006d15 to
adf7163
Compare
This was referenced Sep 30, 2026
4 tasks done
Owner
|
Thanks for this, and for the clear write-up. Per-item constraints are a good fit for mdschema. I've reworked it in #102 on top of #100 and #101, with a few design changes:
You're credited as co-author on the commit. Closing this in favor of #102. Feedback there is very welcome. |
jackchuka
added a commit
that referenced
this pull request
Nov 11, 2026
A list rule could require a list but not constrain what its items say. Add `items` to list rules, applying `required_text` and `forbidden_text` to every top-level item of a matching list. Items are matched against their raw Markdown, and one violation is reported per failing (item, pattern) pair at the item's position. The parser now records each list's items, replacing ItemCount with Items. The literal/regex matching shared by required_text and forbidden_text moves into a single helper. Based on the design in #89. Claude-Session: https://claude.ai/code/session_014K1p9VkeotiX1SR8pLWJSK Co-authored-by: sakanaka <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds
items_must_matchto list rules, so a schema can require every item of a list to follow a format, not just require the list to exist:Why
required_textpasses as soon as one match exists anywhere in the section, andforbidden_textcan only list the spellings to reject one by one. Neither can say "every item must look like this". Approximating it with a complement regex inforbidden_textworks, but the violation shows the regex rather than the offending item.Behavior
required_text(reusingRequiredTextPattern): a plain string is a substring match,{pattern: ...}is a regex.required_text: each item must satisfy every entry. For alternatives, use|in one regex.**Name**keeps its asterisks. The list marker and sub-lists are excluded; wrapped lines are joined with a space.typeare checked. Items of nested sub-lists are skipped.required_text/forbidden_text.Changes
internal/schema/schema.go:ItemsMustMatch []RequiredTextPatternonListRuleinternal/parser/:ListgainsNestedandItems; newListItem{Text, Line, Column}built from the item's first text blockinternal/rules/list.go: item validation; the type filter is extracted intolistMatchesType; generated templates get amust match: ...commentschema.json: regenerated viamdschema schema -o schema.jsonlistsbullet and rules tabletyperespected, multi-line items, generator), loader (both entry forms load without unknown-key warnings)Open questions
items_must_matchwas chosen to read as exclusive ("every item must match"). Happy to rename.RequiredTextPattern, so its JSON Schema description reads "Required text pattern". A dedicated or sharedTextPatterntype may be cleaner.Test plan
go test ./...: all greengo vet ./...: cleangolangci-lint run(v2, repo.golangci.yml): 0 issuesschema.jsonmatches generator output**Card**and`X`are reported; adding a second entry'^\S+$'also reports an item containing spaces (AND)🤖 Generated with Claude Code