# `Spark.Dsl.Verifier`
[🔗](https://github.com/ash-project/spark/blob/v2.7.0/lib/spark/dsl/verifier.ex#L5)

A verifier validates DSL state after compilation without modifying it.

Unlike transformers, verifiers run after the module is compiled, so referencing other
modules (e.g. checking that a related resource exists) will not create compile-time
dependencies between them.

## Usage

    defmodule MyApp.MyExtension.Verifiers.ValidateNames do
      use Spark.Dsl.Verifier

      def verify(dsl_state) do
        case Spark.Dsl.Verifier.get_option(dsl_state, [:my_section], :name) do
          nil -> {:error, Spark.Error.DslError.exception(message: "name is required")}
          _name -> :ok
        end
      end
    end

## Callback

`verify/1` receives the DSL state and should return:

- `:ok` - validation passed
- `{:error, term}` - validation failed
- `{:warn, warning | [warning]}` - validation passed with warnings

## Reading State

This module delegates read-only functions from `Spark.Dsl.Transformer`:
`get_entities/2`, `get_option/3`, `fetch_option/3`, `get_persisted/2`.

## Testing

See `Spark.Test` for ExUnit helpers that turn verifier errors and
warnings into structured data instead of stderr output, so tests can
pattern-match on them:

- `Spark.Test.dsl_errors/1`, `Spark.Test.assert_dsl_error/2`,
  `Spark.Test.refute_dsl_errors/1` for `{:error, _}` returns and raised
  `Spark.Error.DslError` values.
- `Spark.Test.dsl_warnings/1`, `Spark.Test.assert_dsl_warning/2`,
  `Spark.Test.refute_dsl_warnings/1` for `{:warn, _}` returns.

# `warning`

```elixir
@type warning() :: String.t() | {String.t(), :erl_anno.anno()}
```

# `verify`

```elixir
@callback verify(map()) :: :ok | {:error, term()} | {:warn, warning() | [warning()]}
```

# `fetch_option`

# `get_entities`

# `get_option`

# `get_option`

# `get_persisted`

# `get_persisted`

---

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