diff --git a/test/form_test.exs b/test/form_test.exs index a48057a..fede20e 100644 --- a/test/form_test.exs +++ b/test/form_test.exs @@ -794,32 +794,34 @@ defmodule AshPhoenix.FormTest do |> Form.add_form(:embedded_argument, params: %{}) |> Form.validate(%{"embedded_argument" => %{"value" => "you@example.com"}}) |> 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: "you@example.com", - 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: "you@example.com", - 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: "you@example.com", + 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: "you@example.com", + path: [], + class: :invalid + } + ] = nested_form.source.source.errors + + assert nested_form.errors == [{:value, {"must match email", []}}] end end diff --git a/test/support/resources/author.ex b/test/support/resources/author.ex index e6e1fb3..ef7e148 100644 --- a/test/support/resources/author.ex +++ b/test/support/resources/author.ex @@ -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 diff --git a/test/support/validations/validate_embedded_argument.ex b/test/support/validations/validate_embedded_argument.ex index a3b50b7..71940b1 100644 --- a/test/support/validations/validate_embedded_argument.ex +++ b/test/support/validations/validate_embedded_argument.ex @@ -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