fix: handle cases where union type is already atom

This commit is contained in:
Zach Daniel 2023-02-14 16:26:31 -05:00
parent f53ca78f5c
commit 83d0e05bdc

View file

@ -254,7 +254,13 @@ defmodule Ash.Type.Union do
def cast_stored(nil, _), do: {:ok, nil}
def cast_stored(%{"type" => type, "value" => value}, constraints) do
type = String.to_existing_atom(type)
type =
if is_binary(type) do
String.to_existing_atom(type)
else
type
end
types = constraints[:types] || []
case Keyword.fetch(types, type) do