constructor v1.0.0-rc.1 Constructor.Convert

Functions in this module will typically perform a type conversion and then a validation.

Link to this section Summary

Functions

Converts an atom such as :foo to "FOO"

Converts integers, floats and atoms to an equivalent string representation. nil is converted to ""

Link to this section Types

Link to this type

error()
error() :: {:error, String.t()}

Link to this section Functions

Link to this function

nil_to_list(v)
nil_to_list(any()) :: {:ok, list()} | error()

Link to this function

to_atom(item)
to_atom(any()) :: {:ok, atom()} | error()

Link to this function

to_boolean(v)
to_boolean(any()) :: {:ok, boolean()} | error()

Link to this function

to_boolean_or_nil(v)
to_boolean_or_nil(any()) :: {:ok, boolean() | nil} | error()

Link to this function

to_enum_string(e)

Converts an atom such as :foo to "FOO".

Link to this function

to_float(v)
to_float(any()) :: {:ok, float()} | error()

Link to this function

to_float_or_nil(v)
to_float_or_nil(any()) :: {:ok, float() | nil} | error()

Link to this function

to_integer(v)
to_integer(any()) :: {:ok, integer()} | error()

Link to this function

to_integer_or_nil(v)
to_integer_or_nil(any()) :: {:ok, integer() | nil} | error()

Link to this function

to_string(v)
to_string(any()) :: {:ok, String.t()} | error()

Converts integers, floats and atoms to an equivalent string representation. nil is converted to ""

Link to this function

to_string_or_nil(v)
to_string_or_nil(any()) :: {:ok, String.t() | nil} | error()