# `Bylaw.Ecto.Query.Check`
[🔗](https://github.com/ryanzidago/bylaw/blob/v0.1.0-alpha.1/lib/bylaw/ecto/query/check.ex#L1)

Behaviour for checks that validate an `Ecto.Query` before it runs.

Every built-in check implements this callback contract. End users should
usually call `Bylaw.Ecto.Query.validate/3` with an explicit check list instead
of calling check modules directly.

# `operation`

```elixir
@type operation() :: :all | :update_all | :delete_all | :stream | :insert_all
```

The Ecto query operation being prepared.

Ecto calls `c:Ecto.Repo.prepare_query/3` with these operations. Query helpers
such as `Repo.one/2`, `Repo.get/3`, and `Repo.exists?/2` are prepared as
`:all`.

# `opts`

```elixir
@type opts() :: [{atom(), term()}]
```

Check-specific options passed to the check.

# `query`

```elixir
@type query() :: Ecto.Query.t()
```

The query being validated before the repo runs it.

# `result`

```elixir
@type result() :: :ok | {:error, [Bylaw.Ecto.Query.Issue.t(), ...]}
```

The result returned by a query check.

`:ok` means the query passed the check. `{:error, issues}` reports one or
more query issues.

# `validate`

```elixir
@callback validate(operation(), query(), opts()) :: result()
```

Validates a prepared Ecto query for one check.

---

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