Talos v1.0.3 Talos.Types.NumberType View Source

Type for check value is number

For example:


  iex> percents = %Talos.Types.NumberType{gteq: 0, lteq: 100}
  iex> Talos.valid?(percents, 42)
  true
  iex> Talos.valid?(percents, -15)
  false
  iex> Talos.valid?(percents, 30.0)
  true

Additional parameters:

allow_nil - allows value to be nil

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

Link to this type

t()

View Source
t() :: %atom(){
  gteq: number(),
  lteq: number(),
  gt: number(),
  lt: number(),
  allow_nil: boolean(),
  type: :float | :integer | nil
}

Link to this section Functions

Callback implementation for Talos.Types.errors/2.

Link to this function

valid?(number_type, value)

View Source

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