# `Spectre.GAM.Consequence.Validator`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/gam/consequence/validator.ex#L1)

Closed registry of pure, portable consequence validators.

A `Spectre.GAM.Surface` records one validator identifier for every declared
consequence class.  The identifier, rather than a module or callback, is
durable data: admission and an independent auditor can therefore replay the
same rule without executing application code from the ledger.

Ordinary application classes use `none/0`; their complete material shape is
still enforced by `Spectre.GAM.Consequence.Contract`.  Validators in this module
exist only for core transitions whose validity depends on the current
projection or trusted time. Their immutable class binding comes from
`Spectre.GAM.GovernedAct.Class`, not from a callback named in ledger data.

# `id`

```elixir
@type id() :: String.t()
```

# `default_for_class`

```elixir
@spec default_for_class(String.t()) :: id()
```

Returns the built-in default recorded for a class by a new Surface.

# `none`

```elixir
@spec none() :: id()
```

Identifier for classes whose contract needs no projection-dependent rule.

# `validate`

```elixir
@spec validate(id(), Spectre.GAM.Candidate.t(), map(), integer()) ::
  :ok | {:error, term()}
```

Applies the validator selected by the active Surface.

# `validate_binding`

```elixir
@spec validate_binding(String.t(), term()) :: :ok | {:error, term()}
```

Validates the immutable class-to-validator binding recorded by a Surface.

# `validate_id`

```elixir
@spec validate_id(term()) :: :ok | {:error, term()}
```

Validates that an identifier names a deterministic built-in rule.

# `validate_transition`

```elixir
@spec validate_transition(
  id(),
  Spectre.GAM.Candidate.t(),
  Spectre.GAM.Decision.t(),
  Spectre.GAM.Act.t(),
  Spectre.GAM.GovernedAct.State.t()
) :: :ok | {:error, term()}
```

Checks an admitted intrinsic transition against a provisional projection.

---

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