PhoenixApiToolkit.Ecto.Validators.multifield_apply

You're seeing just the function multifield_apply, go back to PhoenixApiToolkit.Ecto.Validators module for more information.
Link to this function

multifield_apply(changeset, fields, function)

View Source

Specs

multifield_apply(
  Ecto.Changeset.t(),
  [atom()],
  (Ecto.Changeset.t(), atom() -> Ecto.Changeset.t())
) :: Ecto.Changeset.t()

Apply function to multiple fields of the changeset. Convenience wrapper for validators that don't support multiple fields.

Examples / doctests

For the implementation of changeset/1, see Elixir.PhoenixApiToolkit.Ecto.Validators.

iex> changeset(%{first_name: "Luke", last_name: "Skywalker"})
...> |> multifield_apply([:first_name, :last_name], &validate_length(&1, &2, max: 3))
...> |> Map.take([:valid?, :errors])
%{valid?: false, errors: [
  {:last_name, {"should be at most %{count} character(s)", [count: 3, validation: :length, kind: :max, type: :string]}},
  {:first_name, {"should be at most %{count} character(s)", [count: 3, validation: :length, kind: :max, type: :string]}}
]}