# `Zoi.Context`
[🔗](https://github.com/phcurado/zoi/blob/v0.17.4/lib/zoi/context.ex#L1)

The Context provides the parsing information such as the input data, parsed data and errors.

The context is passed around during the parsing process to keep track of the current state of parsing.
It contains the schema being parsed, the input data, the parsed data, the path of the current error and any errors that have occurred during parsing.

# `error`

```elixir
@type error() :: Zoi.Error.t() | binary() | [Zoi.Error.t()]
```

# `t`

```elixir
@type t() :: %Zoi.Context{
  errors: [Zoi.Error.t()],
  input: Zoi.input(),
  parsed: Zoi.input(),
  path: Zoi.Error.path(),
  schema: Zoi.schema(),
  valid?: boolean() | nil
}
```

# `add_error`

```elixir
@spec add_error(t(), error()) :: t()
```

Add a error to the context.

## Example

    iex> schema = Zoi.string() |> Zoi.refine(fn input, ctx ->
    ...>   if String.length(input) > 5 do
    ...>     :ok
    ...>   else
    ...>     Zoi.Context.add_error(ctx, "Input too long")
    ...>   end
    ...> end)
    ...> Zoi.parse(schema, "s")
    {:error,
     [
       %Zoi.Error{
         code: :custom,
         issue: {"Input too long", []},
         message: "Input too long",
         path: []
       }
     ]}

---

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