Cherry.Collections.Schema (cherry v0.3.0)

Copy Markdown View Source

Validates frontmatter against a collection schema and introspects schemas for humans and agents.

Frontmatter arrives with string keys straight from YAML; keys are matched against the schema's known atoms (never String.to_atom/1 on user input) and validation errors always name the source file and the field.

Summary

Functions

A schema as introspectable data for --json: name, type, required, default, and doc per field.

Validates a string-keyed meta map; returns an atom-keyed map.

Functions

introspect(schema)

@spec introspect(keyword()) :: [map()]

A schema as introspectable data for --json: name, type, required, default, and doc per field.

validate(meta, schema, source)

@spec validate(map(), keyword(), String.t()) :: {:ok, map()} | {:error, String.t()}

Validates a string-keyed meta map; returns an atom-keyed map.