diff --git a/test/form_test.exs b/test/form_test.exs index 8891043..bfeb333 100644 --- a/test/form_test.exs +++ b/test/form_test.exs @@ -1160,6 +1160,16 @@ defmodule AshPhoenix.FormTest do assert is_nil(Map.get(params, "author", "shouldn't exist")) end + + test "when add_forming a required argument, the added form should be valid without needing to manually validate it" do + form = + Post + |> Form.for_create(:create_author_required, api: Api, forms: [auto?: true]) + |> Form.validate(%{"text" => "foo"}) + |> Form.add_form([:author], params: %{"email" => "james@foo.com"}) + + assert form.valid? == true + end end describe "issue #259" do diff --git a/test/support/resources/post.ex b/test/support/resources/post.ex index a52cfdb..3e5d356 100644 --- a/test/support/resources/post.ex +++ b/test/support/resources/post.ex @@ -25,6 +25,11 @@ defmodule AshPhoenix.Test.Post do change(manage_relationship(:author, type: :direct_control, on_missing: :unrelate)) end + create :create_author_required do + argument(:author, :map, allow_nil?: false) + change(manage_relationship(:author, type: :direct_control, on_missing: :unrelate)) + end + update :update_with_replace do argument(:comments, {:array, :map}) change(manage_relationship(:comments, type: :replace))