# `Spectre.Server.Contracts`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/server/contracts.ex#L1)

Optional application contracts expressed as ordinary Server callbacks.

`assigns_schema/0` returns nil or a field map. Fields are required unless their
type is `{:optional, type}`; undeclared assigns remain permitted. Types are
`:any`, `:string`, `:integer`, `:number`, `:boolean`, `:atom`, `:map`, `:list`,
`{:enum, values}`, `{:list, type}`, `{:map, fields}`, `{:tuple, types}` and
`{:one_of, types}` for alternative result shapes.

`continuation_contracts/0` returns nil or a map from explicit `on_result` tags
to these same schemas. Use tuple and enum types to describe tagged results.
A declared empty map rejects all explicit continuation tags. Built-in implicit
callbacks remain available. These checks do not prove arbitrary Elixir handler
exhaustiveness or infer contracts from catch-all clauses.

# `schema`

```elixir
@type schema() ::
  atom()
  | {:optional, schema()}
  | {:enum, [term()]}
  | {:list, schema()}
  | {:map, map()}
  | {:tuple, [schema()]}
  | {:one_of, [schema()]}
```

# `validate_assigns`

```elixir
@spec validate_assigns(module(), map()) :: :ok | {:error, map()}
```

Checks application assigns without returning values in diagnostics.

# `validate_configuration!`

```elixir
@spec validate_configuration!(module()) :: :ok
```

Validates contract declarations before starting application work.

# `validate_retained`

```elixir
@spec validate_retained(module(), map()) :: :ok | {:error, map()}
```

Checks retained explicit continuations before recovery or a hot upgrade.

---

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