Astral.Schema (Astral v0.2.3)

Copy Markdown View Source

Unified schema adapter for Astral content metadata.

JSON Schema maps, including maps produced by JSONSpec.schema/2, are the preferred collection schema format. Zoi schemas are also supported.

Summary

Functions

Validate and normalize metadata according to the schema.

Detect the supported schema backend.

Convert a supported schema to JSON Schema when possible.

Types

schema_type()

@type schema_type() :: :json_schema | :zoi | :fields | :empty | :unknown

Functions

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

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

Validate and normalize metadata according to the schema.

schema_type(schema)

@spec schema_type(term()) :: schema_type()

Detect the supported schema backend.

to_json_schema(schema)

@spec to_json_schema(term()) :: map() | nil

Convert a supported schema to JSON Schema when possible.