Metadata and construction rules for one signature field.
Prefer the compact signature DSL for ordinary fields. Structured signatures
accept each field as an atom, a "name: type" string, {name, options}, or
a map. A field map accepts atom or string versions of these keys:
name(required) andtype(an atom or string, default:string)kind(:inputor:output, normally supplied by the signature)descandprefixdefault,optional,constraints, andlanguagemetadatafor additional JSON-friendly field metadata
Nested types use the string grammar, for example "array[string]" or
"array[object]"; tuple forms such as {:array, :string} are not accepted.
Constraints are maps such as %{enum: ["red", "blue"]}, %{minimum: 0},
or %{maximum: 1}, keyed by their JSON Schema names; min and max raise. default fills an absent value. optional: true permits
omission and represents it as nil.
iex> field = Imp.Signature.Field.new(%{
...> name: :tags,
...> type: "array[string]",
...> optional: true
...> }, :output)
iex> {field.name, field.type, field.metadata.optional}
{:tags, "array[string]", true}Field declarations describe both sides of the program contract, but input value type mismatches are warning-only at call time for DSPy compatibility. Required input presence and all parsed outputs are enforced.
Summary
Functions
Adds output-validation constraints to a field.
Serializes a field to JSON-friendly data.
Builds a field from an existing field, name, typed name, tuple, or map.
Marks a field optional and nullable.
Types
Functions
Adds output-validation constraints to a field.
Serializes a field to JSON-friendly data.
Loads a field produced by dump/1.
Builds a field from an existing field, name, typed name, tuple, or map.
Marks a field optional and nullable.