fix: cast nil -> {:ok, nil} in all cases

This commit is contained in:
Zach Daniel 2021-05-28 01:47:24 -04:00
parent 0fbf7eab6a
commit f895f3ddd8
2 changed files with 2 additions and 1 deletions

View file

@ -159,7 +159,6 @@ defmodule Ash.EmbeddableType do
end end
end end
def cast_input(nil, _), do: {:ok, nil}
def cast_input(_, _), do: :error def cast_input(_, _), do: :error
def cast_stored(value, constraints) when is_map(value) do def cast_stored(value, constraints) when is_map(value) do

View file

@ -345,6 +345,8 @@ defmodule Ash.Type do
end end
end end
def cast_input(_, nil, _), do: {:ok, nil}
def cast_input(type, term, constraints) do def cast_input(type, term, constraints) do
constraints = Ash.OptionsHelpers.validate!(constraints, constraints(type)) constraints = Ash.OptionsHelpers.validate!(constraints, constraints(type))
type = get_type(type) type = get_type(type)