Skip to content

Commit

Permalink
Merge pull request #1 from ademenev/ash-3-compat
Browse files Browse the repository at this point in the history
Ash framework 3 compatibility
  • Loading branch information
ademenev authored Aug 12, 2024
2 parents aa7c424 + b3f573c commit 3c78ee7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/helpers/form_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,13 @@ defmodule PrimerLive.Helpers.FormHelpers do
ash_changeset.errors
|> Enum.filter(fn ash_error -> ash_error.field == field end)
|> Enum.map(fn ash_error ->
code_to_eval =
if Kernel.function_exported?(Ash.Error.Changes.Required, :id, 1),
do: "Ash.ErrorKind.message(e)",
else: "Exception.message(e)"

{message, _binding} =
Code.eval_string("Ash.ErrorKind.message(e)", [e: ash_error],
Code.eval_string(code_to_eval, [e: ash_error],
file: __ENV__.file,
line: __ENV__.line
)
Expand Down

0 comments on commit 3c78ee7

Please sign in to comment.