Lux.SignalSchema behaviour (Lux v0.5.0)

View Source

Defines the behavior and macros for creating Signal schemas.

Signal schemas define the structure and validation rules for Signal content. They are used to ensure that Signals conform to expected formats and can be properly processed by agents and workflows.

Summary

Functions

Defines a new Signal schema.

Creates a new schema struct from the given attributes.

Recursively converts all map keys to strings in a schema definition.

Types

compatibility()

@type compatibility() :: :full | :backward | :forward | :none

format()

@type format() :: :json | :yaml | :binary | :text

status()

@type status() :: :draft | :active | :deprecated | :retired

t()

@type t() :: %Lux.SignalSchema{
  compatibility: compatibility(),
  created_at: DateTime.t(),
  created_by: String.t(),
  description: String.t() | nil,
  format: format(),
  id: String.t(),
  name: String.t(),
  reference: String.t() | nil,
  schema: map(),
  status: status(),
  tags: [String.t()],
  version: String.t()
}

Callbacks

validate(map, any)

@callback validate(map(), any()) :: {:ok, Lux.Signal.t()} | {:error, any()}

Functions

__using__(opts)

(macro)

Defines a new Signal schema.

Options

  • :name - The name of the schema. Defaults to the module name if not provided.
  • :version - The schema version. Defaults to "1.0.0".
  • :schema - Required. The JSON Schema definition for the Signal content.
  • :description - Optional description of the schema.
  • :tags - Optional list of tags for categorization.
  • :compatibility - Schema compatibility level (:full, :backward, :forward, :none).
  • :status - Schema status (:draft, :active, :deprecated, :retired).
  • :format - Data format (:json, :yaml, :binary, :text).
  • :reference - Optional reference to external schema documentation.

new(attrs)

Creates a new schema struct from the given attributes.

normalize(map)

Recursively converts all map keys to strings in a schema definition.

validate(signal, schema)