Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Nov 28, 2023
1 parent a098a83 commit bace1b1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
50 changes: 26 additions & 24 deletions test/form_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -794,32 +794,34 @@ defmodule AshPhoenix.FormTest do
|> Form.add_form(:embedded_argument, params: %{})
|> Form.validate(%{"embedded_argument" => %{"value" => "[email protected]"}})
|> form_for("action")
[nested_form] = inputs_for(form, :embedded_argument)

[nested_form] = inputs_for(form, :embedded_argument)

# This is the top level error with a path to the nest form.
assert [
%Ash.Error.Changes.InvalidArgument{
field: :value,
message: "must match email",
value: "[email protected]",
path: [:embedded_argument],
class: :invalid
}
] = form.source.source.errors
assert form.errors == []

# This is the error on the nested form.
assert [
%Ash.Error.Changes.InvalidArgument{
field: :value,
message: "must match email",
value: "[email protected]",
path: [],
class: :invalid
}
] = nested_form.source.source.errors
assert nested_form.errors == [{:value, {"must match email", []}}]
# This is the top level error with a path to the nest form.
assert [
%Ash.Error.Changes.InvalidArgument{
field: :value,
message: "must match email",
value: "[email protected]",
path: [:embedded_argument],
class: :invalid
}
] = form.source.source.errors

assert form.errors == []

# This is the error on the nested form.
assert [
%Ash.Error.Changes.InvalidArgument{
field: :value,
message: "must match email",
value: "[email protected]",
path: [],
class: :invalid
}
] = nested_form.source.source.errors

assert nested_form.errors == [{:value, {"must match email", []}}]
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/support/resources/author.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule AshPhoenix.Test.Author do
accept []
argument :embedded_argument, AshPhoenix.Test.EmbeddedArgument, allow_nil?: false

validate { AshPhoenix.Test.ValidateEmbeddedArgument, [] }
validate {AshPhoenix.Test.ValidateEmbeddedArgument, []}
end
end

Expand Down
13 changes: 6 additions & 7 deletions test/support/validations/validate_embedded_argument.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ defmodule AshPhoenix.Test.ValidateEmbeddedArgument do
:ok
else
{:error,
Ash.Error.Changes.InvalidArgument.exception(
field: @embedded_attribute,
message: "must match email",
value: value,
path: [@embedded_argument]
)
}
Ash.Error.Changes.InvalidArgument.exception(
field: @embedded_attribute,
message: "must match email",
value: value,
path: [@embedded_argument]
)}
end
end
end

0 comments on commit bace1b1

Please sign in to comment.