Skip to content

Commit

Permalink
fix: remove system added error vars to ensure deduplication works pro…
Browse files Browse the repository at this point in the history
…perly
  • Loading branch information
zachdaniel committed Dec 28, 2023
1 parent 57dfbab commit fceed87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/ash_phoenix/form_data/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions test/form_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fceed87

Please sign in to comment.