Cherry.Collections.Types (cherry v0.2.0)

Copy Markdown View Source

Shared NimbleOptions custom validators for collection schemas.

YAML frontmatter arrives with string keys and loosely-typed values; these validators normalise into the typed shapes the rest of the pipeline relies on, with error messages that read well after the schema prefixes the source file and field.

Summary

Functions

Validates a cv: curation block (DESIGN.md §4): include, weight, highlights. Returns a Cherry.Portfolio.Curation struct with defaults.

Accepts a Date or an ISO 8601 string.

Validates a links: list: each entry a map with label and url. Returns Cherry.Portfolio.Link structs in the given order.

Functions

validate_cv(value)

@spec validate_cv(term()) ::
  {:ok, Cherry.Portfolio.Curation.t()} | {:error, String.t()}

Validates a cv: curation block (DESIGN.md §4): include, weight, highlights. Returns a Cherry.Portfolio.Curation struct with defaults.

validate_date(date)

@spec validate_date(term()) :: {:ok, Date.t()} | {:error, String.t()}

Accepts a Date or an ISO 8601 string.

validate_links(value)

@spec validate_links(term()) ::
  {:ok, [Cherry.Portfolio.Link.t()]} | {:error, String.t()}

Validates a links: list: each entry a map with label and url. Returns Cherry.Portfolio.Link structs in the given order.