Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type wrapper #208

Merged
merged 1 commit into from
Jun 10, 2024
Merged

type wrapper #208

merged 1 commit into from
Jun 10, 2024

Conversation

revati
Copy link
Contributor

@revati revati commented Jun 8, 2024

If field has type :atom and in form field is empty, and another field is changed, validate works properly, but if i have type:

defmodule AshPhoenix.Test.Action do
  use Ash.Type.NewType, subtype_of: :atom
end

and i use it for attribute attribute(:custom_atom_field, AshPhoenix.Test.Action, public?: true) and field is empty and another field gets changed, validate fails with:

[error] GenServer #PID<0.1775.0> terminating
** (CaseClauseError) no case clause matching: :ok
    (ash 3.0.10) lib/ash/type/type.ex:743: Ash.Type.cast_input/3
    (ash_phoenix 2.0.3) lib/ash_phoenix/form/wrapped_value.ex:35: AshPhoenix.Form.WrappedValue.change_0_generated_AC5F836547B8DDEDB23A9C30C822D686/2
    (ash 3.0.10) lib/ash/changeset/changeset.ex:2196: anonymous fn/6 in Ash.Changeset.run_action_changes/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash 3.0.10) lib/ash/changeset/changeset.ex:2125: Ash.Changeset.run_action_changes/6
    (ash 3.0.10) lib/ash/changeset/changeset.ex:1630: Ash.Changeset.do_for_action/4
    (ash_phoenix 2.0.3) lib/ash_phoenix/form/form.ex:529: AshPhoenix.Form.for_create/3
    (ash_phoenix 2.0.3) lib/ash_phoenix/form/form.ex:4624: AshPhoenix.Form.handle_form_with_params/15
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.3) lib/ash_phoenix/form/form.ex:506: AshPhoenix.Form.for_create/3
    (ash_phoenix 2.0.3) lib/ash_phoenix/form/form.ex:5093: anonymous fn/14 in AshPhoenix.Form.handle_form_with_params_and_data/13
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.3) lib/ash_phoenix/form/form.ex:4955: AshPhoenix.Form.handle_form_with_params_and_data/13
    (ash_phoenix 2.0.3) lib/ash_phoenix/form/form.ex:4624: AshPhoenix.Form.handle_form_with_params/15
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.3) lib/ash_phoenix/form/form.ex:506: AshPhoenix.Form.for_create/3
    (ash_phoenix 2.0.3) lib/ash_phoenix/form/form.ex:1289: anonymous fn/9 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_phoenix 2.0.3) lib/ash_phoenix/form/form.ex:1269: anonymous fn/7 in AshPhoenix.Form.validate_nested_forms/6
    (elixir 1.16.2) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3

@zachdaniel zachdaniel merged commit 2970af4 into ash-project:main Jun 10, 2024
14 of 15 checks passed
@zachdaniel
Copy link
Contributor

zachdaniel commented Jun 10, 2024

The fix for this was actually in ash, here: ash-project/ash@46450f7

@zachdaniel
Copy link
Contributor

🚀 Thank you for your contribution! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants