Skip to content

Why not use JSON Schema for frontmatter validation? #14

Description

@tonyxiao

Summary

Has the project considered adopting JSON Schema for frontmatter validation instead of a separate custom field/type format in _types/*.md?

Context

I'm evaluating mdbase for a typed Markdown collection and the path/type matching model makes sense, but the schema layer appears to reinvent functionality that JSON Schema already covers for validating YAML frontmatter fields.

Examples of the current custom schema surface include:

  • custom scalar/object/list field definitions
  • required, enum, nested fields, nested items
  • collection-specific validation semantics layered on top

Question

Was the custom schema format chosen intentionally over JSON Schema for a specific reason?

More concretely:

  1. Was JSON Schema considered and rejected?
  2. If so, what limitations made it a poor fit?
  3. Could mdbase support JSON Schema for frontmatter validation while keeping the markdown-specific parts (match.path_glob, link, query/formula features, rename semantics, etc.) in its own config layer?
  4. If not, what is the main advantage of the current custom schema format over reusing JSON Schema for field validation?

Why I'm asking

From a consumer perspective, JSON Schema would seem to offer a few advantages:

  • reuse of existing tooling and validators
  • less custom syntax to learn
  • easier interoperability with TypeScript/codegen/editor tooling
  • a clearer separation between document validation and collection-specific behavior

I can see why mdbase needs custom collection behavior, but I don't yet see why that necessarily implies a custom field schema language too.

Curious whether this was a deliberate product decision, an implementation simplification, or something else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions