# `Imp.Signature.Field`
[🔗](https://github.com/deepfates/imp/blob/v0.18.1/lib/imp/signature/field.ex#L1)

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) and `type` (an atom or string, default `:string`)
  * `kind` (`:input` or `:output`, normally supplied by the signature)
  * `desc` and `prefix`
  * `default`, `optional`, `constraints`, and `language`
  * `metadata` for 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.

# `t`

```elixir
@type t() :: %Imp.Signature.Field{
  desc: String.t() | nil,
  kind: :input | :output,
  metadata: map(),
  name: atom() | String.t(),
  prefix: String.t() | nil,
  type: atom() | String.t()
}
```

# `constrained`

Adds output-validation constraints to a field.

# `dump`

Serializes a field to JSON-friendly data.

# `load`

Loads a field produced by `dump/1`.

# `new`

Builds a field from an existing field, name, typed name, tuple, or map.

# `optional`

Marks a field optional and nullable.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
