# `Exdantic.Error`
[🔗](https://github.com/nshkrdotcom/exdantic/blob/v0.1.0/lib/exdantic/error.ex#L1)

Structured error representation for Exdantic validation errors.

# `t`

```elixir
@type t() :: %Exdantic.Error{
  code: atom(),
  message: String.t(),
  path: [atom() | String.t()]
}
```

# `format`

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

Formats an error into a human-readable string.

## Examples

    iex> error = %Exdantic.Error{path: [:user, :email], code: :format, message: "invalid format"}
    iex> Exdantic.Error.format(error)
    "user.email: invalid format"

    iex> error = %Exdantic.Error{path: [], code: :type, message: "expected string"}
    iex> Exdantic.Error.format(error)
    ": expected string"

# `new`

```elixir
@spec new([atom() | String.t()] | atom() | String.t(), atom(), String.t()) :: t()
```

Creates a new validation error.

## Parameters
  * `path` - Path to the field that caused the error
  * `code` - Error code identifying the type of error
  * `message` - Human-readable error message

## Examples

    iex> Exdantic.Error.new([:user, :email], :format, "invalid email format")
    %Exdantic.Error{path: [:user, :email], code: :format, message: "invalid email format"}

    iex> Exdantic.Error.new(:name, :required, "field is required")
    %Exdantic.Error{path: [:name], code: :required, message: "field is required"}

---

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