View Source Parameter.Types (Parameter v0.5.4)

Parameter supports different types to be used in the field inside a schema. The available types are:

  • string
  • atom
  • any
  • integer
  • float
  • boolean
  • map
  • array
  • date
  • time
  • datetime
  • naive_datetime
  • decimal*
  • enum**

* For decimal type add the decimal library into your project.

** Check the Parameter.Enum for more information on how to use enums.

For implementing custom types check the Parameter.Parametrizable module. Implementing this behavour in a module makes eligible to be a field in the schema definition.

Link to this section Summary

Link to this section Types

@type base_types() ::
  :string
  | :atom
  | :any
  | :boolean
  | :date
  | :datetime
  | :decimal
  | :float
  | :integer
  | :list
  | :map
  | :naive_datetime
  | :string
  | :time
@type composite_types() :: {:has_many, t()} | {:has_one, t()}
@type t() :: base_types() | composite_types()

Link to this section Functions

@spec base_types() :: [atom()]
@spec composite_types() :: [atom()]
@spec dump(atom(), any()) :: {:ok, any()} | {:error, any()}
@spec load(atom(), any()) :: {:ok, any()} | {:error, any()}
@spec validate(atom(), any()) :: :ok | {:error, any()}
@spec validate!(atom(), any()) :: :ok | no_return()