From fceed874e6b7f969073026b39143badf0f37fe83 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Thu, 28 Dec 2023 15:42:47 -0500 Subject: [PATCH] fix: remove system added error vars to ensure deduplication works properly --- lib/ash_phoenix/form_data/helpers.ex | 2 ++ test/form_test.exs | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/ash_phoenix/form_data/helpers.ex b/lib/ash_phoenix/form_data/helpers.ex index 365996c..9b56a9e 100644 --- a/lib/ash_phoenix/form_data/helpers.ex +++ b/lib/ash_phoenix/form_data/helpers.ex @@ -187,6 +187,8 @@ defmodule AshPhoenix.FormData.Helpers do [] end end) + # Drop known system added vars + |> Keyword.drop([:path, :index, :field, :message]) end def transform_error(form, error) do diff --git a/test/form_test.exs b/test/form_test.exs index 42b2b83..88b1bf5 100644 --- a/test/form_test.exs +++ b/test/form_test.exs @@ -861,16 +861,13 @@ defmodule AshPhoenix.FormTest do # Note: I'm not 100% which of the 3 errors messages are preferred. The opts are get_text bindings for error translation # In the Phoenix core components the error translation is done `Gettext.dpgettext(MyApp.Gettext, domain, msgctxt, msgid, bindings)` with our tuple being `{msgid, bindings}` assert Keyword.get_values(inputs_for_nested_form.errors, :limit) == [ - {"is invalid", [field: "limit", message: "is invalid", index: 0]} + {"is invalid", []} ] assert Keyword.get_values(inputs_for_nested_form.errors, :four_chars) == [ {"must have length of exactly %{exact}", [ - field: "four_chars", - message: "must have length of exactly %{exact}", - exact: 4, - index: 0 + exact: 4 ]} ] end