Tune.Parameter (Tune v0.5.0)

Copy Markdown View Source

A tunable JSON value with a Zoi schema, such as a lesson list or candidate text.

Application code reads it with Tune.Execution.value/2 and decides how to use it. Optimizers replace the value; the schema is code-owned and every new value is validated against it.

Summary

Functions

Builds a parameter.

Returns the parameter with a new validated value.

Validates a value against a parameter schema.

Types

t()

@type t() :: %Tune.Parameter{
  description: String.t() | nil,
  schema: Zoi.schema(),
  value: term()
}

Functions

new(opts)

@spec new(keyword()) :: {:ok, t()} | {:error, Exception.t()}

Builds a parameter.

Options: :schema (required JSON-compatible Zoi schema), :value (required), and :description.

put_value(parameter, value)

@spec put_value(t(), term()) :: {:ok, t()} | {:error, Exception.t()}

Returns the parameter with a new validated value.

validate(schema, value)

@spec validate(Zoi.schema(), term()) :: {:ok, term()} | {:error, Exception.t()}

Validates a value against a parameter schema.