Skip to content

Commit

Permalink
Fix for :any type casting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Warren Kenny committed Nov 21, 2024
1 parent 541adcb commit e42c3cc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/want/keyword.ex
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ defmodule Want.Keyword do
nil -> {:error, "key #{inspect key} not found"}
end
end
def cast(input, :any, _opts),
do: {:ok, input}
def cast(input, key, opts) when (is_list(input) or (is_map(input) and not is_struct(input))) and not is_nil(key) and is_atom(key) do
cond do
Want.Shape.is_shape?(key) -> Want.Shape.cast(key, input)
Expand Down Expand Up @@ -254,8 +256,6 @@ defmodule Want.Keyword do
do: Want.DateTime.cast(input, opts)
def cast(input, :date, opts),
do: Want.Date.cast(input, opts)
def cast(input, :any, _opts),
do: {:ok, input}
def cast(input, type, opts) do
if Want.Type.is_custom_type?(type) do
Want.Type.cast(type, input, opts)
Expand Down
4 changes: 2 additions & 2 deletions lib/want/map.ex
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ defmodule Want.Map do
nil -> {:error, "key #{inspect key} not found"}
end
end
def cast(input, :any, _opts),
do: {:ok, input}
def cast(input, key, opts) when (is_list(input) or (is_map(input) and not is_struct(input))) and is_atom(key) and not is_nil(key) do
cond do
Want.Shape.is_shape?(key) -> Want.Shape.cast(key, input)
Expand Down Expand Up @@ -264,8 +266,6 @@ defmodule Want.Map do
do: Want.Date.cast(input, opts)
def cast(input, nil, opts) when is_map(opts),
do: cast(input, opts)
def cast(input, :any, _opts),
do: {:ok, input}
def cast(input, type, opts) do
if Want.Type.is_custom_type?(type) do
Want.Type.cast(type, input, opts)
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Want.MixProject do
use Mix.Project

@source_url "https://github.com/wrren/want.erl"
@version "1.17.0"
@version "1.17.1"

def project do
[
Expand Down

0 comments on commit e42c3cc

Please sign in to comment.