Talos.Types.FixedType (Talos v1.12.1) View Source

Fixed type is used to check value to be equal expected

For example:

  iex> import Talos, only: [fixed: 1]
  iex> the_4th_planet = fixed(value: "Mars")
  iex> Talos.valid?(the_4th_planet, "Earth")
  false
  iex> Talos.valid?(the_4th_planet, "Mars")
  true
  

Additional parameters: allow_nil - allows value to be nil

Link to this section Summary

Functions

Callback implementation for Talos.Types.errors/2.

Callback implementation for Talos.Types.valid?/2.

Link to this section Types

Specs

t() :: %{__struct__: atom(), allow_nil: boolean(), example_value: any()}

Link to this section Functions

Callback implementation for Talos.Types.errors/2.

Specs

valid?(t(), any()) :: boolean()

Callback implementation for Talos.Types.valid?/2.