Skip to content

Coerce strict numeric strings on schema number/integer fields in markdown plugin - #280

Merged
mindsocket merged 1 commit into
mainfrom
feat/markdown-coerce-numeric-strings
Dec 1, 2026
Merged

mindsocket merged 1 commit into
mainfrom
feat/markdown-coerce-numeric-strings

Conversation

@mindsocket

Copy link
Copy Markdown
Owner

Summary

  • Add coerceNumericFields() in src/plugins/markdown/util.ts and run it at the end of readSpaceDirectory() and readSpaceOnAPage().
    • Inspects each node type's resolved schema properties (including allOf / $ref and both const and enum type discriminators) to find fields typed as number or integer (excluding union types that also allow string).
    • Coerces strict numeric strings (/^-?\d+(?:\.\d+)?$/ after trimming, finite) to JS numbers across frontmatter, inline [field:: value], and embedded nodes.
    • Leaves non-numeric strings (e.g. "abc", "") untouched so schema validation still reports them, and never touches type: "string" fields.
  • Add end-to-end test in tests/plugins/markdown/coerce-numeric-fields.test.ts.

Test plan

  • bun test tests/plugins/markdown/ tests/module-boundaries.test.ts (173 pass, 0 fail)
  • bun run typecheck
  • bun run lint

@claude

claude Bot commented Dec 1, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@mindsocket
mindsocket merged commit 6efaf92 into main Dec 1, 2026
2 checks passed
@mindsocket
mindsocket deleted the feat/markdown-coerce-numeric-strings branch December 1, 2026 11:35
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.

1 participant