Basics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of normal and works with any version of Elixir.
Explanation
Flags handle_event/3 clauses whose params pattern requires a form
field the form never sends. The clause cannot match the form's
params, so submitting raises FunctionClauseError or falls through
to another clause.
Before:
<.form for={@form} phx-submit="save">
<.input field={@form[:email]} />
</.form>
def handle_event("save", %{"user" => %{"email" => email, "name" => name}}, socket)After:
<.form for={@form} phx-submit="save">
<.input field={@form[:email]} />
<.input field={@form[:name]} />
</.form>The form's name comes from to_form(data, as: name) or from the
schema struct in the changeset (%MyApp.Accounts.User{} sends
user[...]). Its fields are the keys it reads as @form[:key] (or
through :let) and literal name="user[key]" attributes. The check
stays silent when it cannot resolve the form's name, or when the
form is passed whole to a component that could add fields. Keys
starting with _ are ignored.
Confidence: medium. Tier: syntactic (works without compiling).
Check-Specific Parameters
Use the following parameters to configure this check:
:excluded_paths
Paths to skip (atoms, binaries as path segments, or regexes).
This parameter defaults to [~r/\/test\//, "test"].
:strict
Unused.
This parameter defaults to false.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.