RequestSeal.StructuredFields.Schema (RequestSeal v0.2.0)

Copy Markdown View Source

Explicit field type restrictions and RFC revision (RFC 9651 Section 2).

new/1 requires a map containing :revision (:rfc8941 or :rfc9651), :type (:item, :list, or :dictionary), and nonempty :item_types. Bare types are :integer, :decimal, :string, :token, :bytes, and :boolean; RFC 9651 additionally allows :date and :display_string. :inner_lists defaults to false. :parameter_types defaults to all types in the selected revision. These restrictions apply to every item, including inner-list items, and every parameter, respectively. Unknown options reject.

This is a type schema, not a complete field protocol or profile. The caller selects it from the field's normative specification and checks any additional semantic rules. No field name or recognized syntax selects a newer revision. Directly constructed schemas undergo the same validation at each entry point.

Summary

Functions

Construct an explicit type schema; no revision or item-type defaults.

Types defined by the selected revision; invalid revisions return an empty list.

Validate revision, top-level type, and all bare-type restrictions.

Types

bare_type()

@type bare_type() ::
  :integer
  | :decimal
  | :string
  | :token
  | :bytes
  | :boolean
  | :date
  | :display_string

t()

@type t() :: %RequestSeal.StructuredFields.Schema{
  inner_lists: boolean(),
  item_types: [bare_type()],
  parameter_types: [bare_type()],
  revision: :rfc8941 | :rfc9651,
  type: :item | :list | :dictionary
}

Functions

new(attrs)

@spec new(map()) :: {:ok, t()} | {:error, RequestSeal.StructuredFields.Error.t()}

Construct an explicit type schema; no revision or item-type defaults.

types(arg1)

Types defined by the selected revision; invalid revisions return an empty list.

validate(s)

@spec validate(term()) :: :ok | {:error, RequestSeal.StructuredFields.Error.t()}

Validate revision, top-level type, and all bare-type restrictions.