# `Peri.Form`
[🔗](https://github.com/zoedsoupe/peri/blob/v0.11.2/lib/peri/form.ex#L1)

A form-ready struct holding Peri validation results.

`Peri.Phoenix.to_form/3` builds this struct from a schema and raw params,
and the `Phoenix.HTML.FormData` implementation (available when
`phoenix_html` is loaded) converts it into a `Phoenix.HTML.Form`, so
Peri schemas plug into `Phoenix.Component.form/1` and `<.input>` without
Ecto.

## Fields

  * `:schema` - the Peri schema the params were validated against
  * `:data` - the validated data (atom keys), `%{}` when validation failed
  * `:params` - the raw params as received (usually string keys)
  * `:errors` - errors in changeset format, `%{field => [{message, opts}]}`
    with nested humanized maps under assoc keys (list entries keyed by index)
  * `:name` - the form name, defaults to `"peri"`
  * `:action` - the form action (`:validate`, `:save`, ...), used by
    LiveView to decide when to show errors

# `errors`

```elixir
@type errors() :: %{optional(atom()) =&gt; [{String.t(), keyword()}] | errors()}
```

# `t`

```elixir
@type t() :: %Peri.Form{
  action: atom() | nil,
  data: map(),
  errors: errors(),
  name: String.t() | nil,
  params: map(),
  schema: Peri.schema() | nil
}
```

---

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