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

Add post_process_errors option #313

Open
zachdaniel opened this issue Feb 19, 2025 · 0 comments
Open

Add post_process_errors option #313

zachdaniel opened this issue Feb 19, 2025 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@zachdaniel
Copy link
Contributor

Often times, users want to conditionally decide to show errors, or modify them in some way. We have transform_errors, which gives you the Ash error struct, like %Ash.Error.Changes.InvalidChanges{}, but that can be annoying because you have to handle the conversion to to the triple, i.e {:field, "message", vars: []} before doing any work. So we should add an option that takes a callback like so:

# (can path be gotten from the form instead?)
post_process_errors: fn form, path_to_form, {field, message, vars} -> 
  # you could for example filter certain errors out
  # maybe using Phoenix.used_input?(form.raw_params, field)
  # or other custom criteria
  # or remap the field name from one thing to another
end
@zachdaniel zachdaniel added enhancement New feature or request good first issue Good for newcomers labels Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant