mayo v0.2.0 Mayo.Number

Summary

Functions

Check if the number is even

Check if the number is a float

Checks if the number is greater than the limit

Check if the number is an integer

Checks if the number is less than the limit

Checks the maximum value of a number

Checks the minimum value of a number

Checks if the number is negative

Check if the number is odd

Checks if the number is positive

Functions

even(value)

Check if the number is even.

iex> Mayo.Number.even(2)
2

iex> Mayo.Number.even(1)
{:error, %Mayo.Error{type: "number.even"}}
float(value)

Check if the number is a float.

iex> Mayo.Number.float(3.14)
3.14

iex> Mayo.Number.float(3)
{:error, %Mayo.Error{type: "number.float"}}
greater(value, limit)

Checks if the number is greater than the limit.

iex> Mayo.Number.greater(4, 3)
4

iex> Mayo.Number.greater(3, 3)
{:error, %Mayo.Error{type: "number.greater"}}
integer(value)

Check if the number is an integer.

iex> Mayo.Number.integer(2)
2

iex> Mayo.Number.integer(3.14)
{:error, %Mayo.Error{type: "number.integer"}}
less(value, limit)

Checks if the number is less than the limit.

iex> Mayo.Number.less(2, 3)
2

iex> Mayo.Number.less(3, 3)
{:error, %Mayo.Error{type: "number.less"}}
max(value, limit)

Checks the maximum value of a number.

iex> Mayo.Number.max(4, 5)
4

iex> Mayo.Number.max(6, 5)
{:error, %Mayo.Error{type: "number.max"}}
min(value, limit)

Checks the minimum value of a number.

iex> Mayo.Number.min(4, 3)
4

iex> Mayo.Number.min(1, 3)
{:error, %Mayo.Error{type: "number.min"}}
negative(value)

Checks if the number is negative.

iex> Mayo.Number.negative(-2)
-2

iex> Mayo.Number.negative(0)
0

iex> Mayo.Number.negative(2)
{:error, %Mayo.Error{type: "number.negative"}}
odd(value)

Check if the number is odd.

iex> Mayo.Number.odd(1)
1

iex> Mayo.Number.odd(2)
{:error, %Mayo.Error{type: "number.odd"}}
positive(value)

Checks if the number is positive.

iex> Mayo.Number.positive(2)
2

iex> Mayo.Number.positive(0)
0

iex> Mayo.Number.positive(-2)
{:error, %Mayo.Error{type: "number.positive"}}