-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: properly return nested errors with
for_path: :all
- Loading branch information
1 parent
bace1b1
commit c292848
Showing
3 changed files
with
74 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,7 +174,6 @@ defmodule AshPhoenix.FormTest do | |
|> Form.for_create(:create_author_required, api: Api, forms: [auto?: true]) | ||
|> Form.validate(%{"list_of_ints" => %{"0" => %{"map" => "of stuff"}}}) | ||
|
||
# TODO: this might be wrong | ||
assert AshPhoenix.Form.value(form, :list_of_ints) == %{"0" => %{"map" => "of stuff"}} | ||
end | ||
end | ||
|
@@ -795,33 +794,11 @@ defmodule AshPhoenix.FormTest do | |
|> Form.validate(%{"embedded_argument" => %{"value" => "[email protected]"}}) | ||
|> form_for("action") | ||
|
||
[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 AshPhoenix.Form.errors(form, for_path: [:embedded_argument]) == [ | ||
value: "must match email" | ||
] | ||
|
||
assert nested_form.errors == [{:value, {"must match email", []}}] | ||
assert AshPhoenix.Form.errors(form) == [] | ||
end | ||
end | ||
|
||
|