Current section
Files
Jump to
Current section
Files
lib/parameter/types/any.ex
defmodule Parameter.Types.Any do
@moduledoc """
Any parameter type. It will accept any input value without validations.
The same value loaded will be the same dumped.
"""
@behaviour Parameter.Parametrizable
@doc """
`Any` type will just return the same type value that is passed to load function
## Examples
iex> Parameter.Types.Any.load(:any_atom)
{:ok, :any_atom}
iex> Parameter.Types.Any.load("some string")
{:ok, "some string"}
iex> Parameter.Types.Any.load(nil)
{:ok, nil}
"""
@impl true
def load(value), do: {:ok, value}
@doc """
`Any` type will just return the same type value that is passed to dump function
## Examples
iex> Parameter.Types.Any.load(:any_atom)
{:ok, :any_atom}
iex> Parameter.Types.Any.load("some string")
{:ok, "some string"}
iex> Parameter.Types.Any.load(nil)
{:ok, nil}
"""
@impl true
def dump(value), do: {:ok, value}
@doc """
Always return `:ok`, any value is valid
"""
@impl true
def validate(_value), do: :ok
end