View Source Parameter.Types (Parameter v0.12.1)

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

  • string
  • atom
  • any
  • integer
  • float
  • boolean
  • map
  • {map, nested_type}
  • array
  • {array, nested_type}
  • 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
  | :naive_datetime
  | :string
  | :time
  | :array
  | :map
@type composite_types() :: {:array, t()} | {:map, t()}
@type t() :: base_types() | composite_types()

Link to this section Functions

@spec base_type?(any()) :: boolean()
Link to this function

composite_inner_type?(arg1)

View Source
@spec composite_inner_type?(any()) :: boolean()
@spec composite_type?(any()) :: boolean()
@spec dump(atom(), any()) :: {:ok, any()} | {:error, any()}
@spec load(atom(), any()) :: {:ok, any()} | {:error, any()}
@spec validate(t(), any()) :: :ok | {:error, any()}
@spec validate!(t(), any()) :: :ok | no_return()