Invoicex v1.0.0-rc.0 Invoicex.Enum.ContactNumberType View Source

Stores supported contact number types.

Link to this section Summary

Functions

Casts the given input to the custom type

Creates database enum

Drops database enum

Dumps the given term into an Ecto native type

Loads the given term into a custom type

Returns database enum type

Check if specifed argument is valid element of enum

Link to this section Functions

Link to this function cast(atom) View Source
cast(value) :: value when value: atom()
cast(String.t()) :: atom()
cast(term()) :: :error

Casts the given input to the custom type.

This callback is called on external input and can return any type, as long as the dump/1 function is able to convert the returned value into an Ecto native type. There are two situations where this callback is called:

  1. When casting values by Ecto.Changeset
  2. When passing arguments to Ecto.Query

Callback implementation for Ecto.Type.cast/1.

Link to this function create_db_enum() View Source
create_db_enum() :: :ok

Creates database enum

Link to this function drop_db_enum() View Source
drop_db_enum() :: :ok

Drops database enum

Link to this function dump(atom) View Source
dump(atom()) :: {:ok, String.t()}
dump(value) :: value when value: String.t()
dump(term()) :: :error

Dumps the given term into an Ecto native type.

This callback is called with any term that was stored in the struct and it needs to validate them and convert it to an Ecto native type.

Callback implementation for Ecto.Type.dump/1.

Link to this function load(value) View Source
load(value) :: {:ok, value} when value: atom()
load(term()) :: :error

Loads the given term into a custom type.

This callback is called when loading data from the database and receive an Ecto native type. It can return any type, as long as the dump/1 function is able to convert the returned value back into an Ecto native type.

Callback implementation for Ecto.Type.load/1.

Returns database enum type

Link to this macro valid_value?(value) View Source (macro)
valid_value?(term()) :: boolean()

Check if specifed argument is valid element of enum.