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

Type for check value is integer

For example:

  iex> import Talos, only: [integer: 1]
  iex> percents = integer(gteq: 0, lteq: 100)
  iex> Talos.valid?(percents, 42)
  true
  iex> Talos.valid?(percents, -15)
  false
  iex> Talos.valid?(percents, 30.0)
  false

Additional parameters:

allow_nil - allows value to be nil

allow_blank - allows value to be blank (0)

gteq - greater than or equal, same as >=

lteq - lower than or equal, same as <=

gt - lower than, same as >

lt - lower than, same as <

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(),
  gteq: nil | integer(),
  lteq: nil | integer(),
  gt: nil | integer(),
  lt: nil | integer(),
  allow_blank: boolean(),
  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.