# `Alternera.Plugin.Provisional.Checks`
[🔗](https://github.com/10e-ab/alternera-sdk/blob/v0.9.0/alternera_plugin_sdk/lib/alternera/plugin/provisional/checks.ex#L1)

Provisional: added for the Response cache, and a change to it needs a
changelog line but no new major (`docs/USER_PLUGINS_DESIGN.md`).

A step's settings checked where the step stands, on a save. `init/1` sees
the settings alone; a plugin whose settings name things only the pipeline
knows (the side a condition is read on, the proxy's cache vocabulary)
exports `flow_errors/2`, which the proxy's flow check calls with the whole
stored step and its place, after its own checks of where the step may
stand have passed. The messages it answers are the step's, prefixed with
its label by the proxy.

The checks it needs of the proxy go through `Alternera.Plugin.Host`:

  * `condition_errors/2`: a list of conditions read on a side, each as the
    pipeline's own conditions are checked;
  * `cache_settings_errors/1`: a cache's key, `ttl`, `wait_ms`, `store`,
    `response` rules and `limits`, as a cache container's are checked;
  * `cache_key_reads_body?/1`: whether a cache key reads the request body.

On the SDK's test host (`Alternera.Plugin.Test.Host`), as in a
plugin's own tests, the conditions are checked for their shape only and
the cache settings not at all.

# `place`

```elixir
@type place() :: %{
  section: :before | :implementation | :after | :on_error,
  side: atom()
}
```

Where the step stands: its section and the side it runs on (`:request`,
`:response`, `:implementation` for an Implementation's own steps, or
`:on_error`).

# `flow_errors`

```elixir
@callback flow_errors(step :: map(), place()) :: [String.t()]
```

What is wrong with `step` (the stored step, string keys: `"settings"`,
`"id"`, `"on_error"`…) at `place`, as messages; `[]` when nothing is.

# `cache_key_reads_body?`

```elixir
@spec cache_key_reads_body?(term()) :: boolean()
```

Whether a cache key template reads the request body.

# `cache_settings_errors`

```elixir
@spec cache_settings_errors(map()) :: [String.t()]
```

What is wrong with a cache's settings (string keys), as a cache container's are checked.

# `condition_errors`

```elixir
@spec condition_errors(term(), :request | :response) :: [String.t()]
```

What is wrong with `conditions` read on `side` (`:request` or
`:response`), one message per wrong condition, `"condition <n>: …"`
(1-based).

---

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