# `Bylaw.Db.Issue`
[🔗](https://github.com/ryanzidago/bylaw/blob/v0.1.0-alpha.1/lib/bylaw/db/issue.ex#L1)

Issue returned by a failed database validation check.

# `format_opt`

```elixir
@type format_opt() :: {:meta, boolean()}
```

Formatting option.

# `format_opts`

```elixir
@type format_opts() :: [format_opt()]
```

Formatting options.

# `t`

```elixir
@type t() :: %Bylaw.Db.Issue{
  check: module(),
  message: String.t(),
  meta: map(),
  target: Bylaw.Db.Target.t() | nil
}
```

A database validation issue.

`check` identifies the check module that produced the issue, `message` is the
human-readable failure text, `target` is the target that failed when available,
and `meta` holds structured adapter- or check-specific details.

# `format`

```elixir
@spec format(t()) :: String.t()
```

Formats a database issue for human-readable error output.

Metadata is omitted by default because issue messages are meant for humans and
often already contain the actionable details. Pass `meta: true` to include the
structured metadata for debugging.

## Examples

    iex> issue = %Bylaw.Db.Issue{
    ...>   check: MyApp.RequiredColumns,
    ...>   message: "users.email is nullable",
    ...>   meta: %{table: :users}
    ...> }
    iex> Bylaw.Db.Issue.format(issue)
    "MyApp.RequiredColumns: users.email is nullable"

    iex> issue = %Bylaw.Db.Issue{
    ...>   check: MyApp.RequiredColumns,
    ...>   message: "users.email is nullable",
    ...>   meta: %{table: :users}
    ...> }
    iex> Bylaw.Db.Issue.format(issue, meta: true)
    "MyApp.RequiredColumns: users.email is nullable %{table: :users}"

# `format`

```elixir
@spec format(t(), format_opts()) :: String.t()
```

Formats a database issue for human-readable error output.

# `format_many`

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

Formats many database issues for human-readable error output.

## Examples

    iex> issues = [
    ...>   %Bylaw.Db.Issue{check: MyApp.RequiredColumns, message: "users.email is nullable"},
    ...>   %Bylaw.Db.Issue{check: MyApp.RequiredColumns, message: "posts.account_id is nullable"}
    ...> ]
    iex> Bylaw.Db.Issue.format_many(issues)
    "MyApp.RequiredColumns: users.email is nullable\nMyApp.RequiredColumns: posts.account_id is nullable"

# `format_many`

```elixir
@spec format_many([t()], format_opts()) :: String.t()
```

Formats many database issues for human-readable error output.

---

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