mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
improvement: discard certain empty values for embed input
This commit is contained in:
parent
e57a61b16f
commit
3e7b798e34
2 changed files with 7 additions and 0 deletions
|
@ -261,6 +261,10 @@ defmodule Ash.EmbeddableType do
|
|||
end
|
||||
end
|
||||
|
||||
def prepare_change(old_value, "", constraints) do
|
||||
prepare_change(old_value, nil, constraints)
|
||||
end
|
||||
|
||||
def prepare_change(_old_value, nil, _constraints) do
|
||||
{:ok, nil}
|
||||
end
|
||||
|
|
|
@ -260,6 +260,9 @@ defmodule Ash.Type do
|
|||
@spec cast_input(t(), term, constraints | nil) :: {:ok, term} | {:error, Keyword.t()} | :error
|
||||
def cast_input(type, term, constraints \\ [])
|
||||
|
||||
def cast_input({:array, type}, empty, constraints) when empty in [nil, ""],
|
||||
do: cast_input({:array, type}, [], constraints)
|
||||
|
||||
def cast_input({:array, _type}, term, _) when not is_list(term) do
|
||||
{:error,
|
||||
message: "must be a list or a map of integer indices (string encoded or not) to values"}
|
||||
|
|
Loading…
Reference in a new issue