Astral.Schema.Fields (Astral v0.2.0)

Copy Markdown View Source

Ecto-style field schema for collection metadata.

This is the internal representation for:

schema do
  field :title, :string, required: true
  field :date, :date, required: true
  field :draft, :boolean, default: false
  field :tags, {:array, :string}, default: []
end

The public DSL intentionally mirrors Ecto's field/3 shape. Astral uses Ecto schemaless changesets internally to cast external frontmatter, apply field defaults, and validate required fields.

Summary

Functions

Normalize string-keyed metadata through Ecto casting and validation.

Types

t()

@type t() :: %Astral.Schema.Fields{fields: [Astral.Schema.Field.t()]}

Functions

normalize(schema, metadata, opts \\ [])

@spec normalize(t(), map(), keyword()) :: {:ok, map()} | {:error, term()}

Normalize string-keyed metadata through Ecto casting and validation.