BoundNumber
BoundTypes.BoundNumber
— TypeBoundNumber{N<:Number} <: Number
Abstract type for number constraints.
NumberCustomBound
BoundTypes.NumberCustomBound
— TypeNumberCustomBound{T<:Number,B} <: BoundNumber{T}
NumberCustomBound{T,B}(x::Number)
A number constraint for a value x
of type T
using custom function B
. Function B
should only accept object x
and return true
or false
(or throw a custom ConstraintError
).
Examples
julia> NumberCustomBound{Float64,x -> x % 2 == 0}(10.0)
10.0
julia> NumberCustomBound{Float64,x -> x % 2 == 0}(13.0)
ERROR: ConstraintError: constraints of type NumberCustomBound violated.
Wrong value: Custom constraint '#7' violated for value "13.0" of type Float64.
[...]
NumberPositive
BoundTypes.NumberPositive
— TypeNumberPositive{T<:Number} <: BoundNumber{T}
NumberPositive{T}(x::Number)
A number constraint that enforces x > 0
for value x
of type T
.
Examples
julia> NumberPositive{Float64}(10.0)
10.0
julia> NumberPositive{Float64}(-10.0)
ERROR: ConstraintError: constraints of type NumberPositive violated.
Wrong value: number -10.0 must be a positive (x > 0).
[...]
NumberNegative
BoundTypes.NumberNegative
— TypeNumberNegative{T<:Number} <: BoundNumber{T}
NumberNegative{T}(x::Number)
A number constraint that enforces x < 0
for value x
of type T
.
Examples
julia> NumberNegative{Float64}(-10.0)
-10.0
julia> NumberNegative{Float64}(10.0)
ERROR: ConstraintError: constraints of type NumberNegative violated.
Wrong value: 10.0 must be a negative (x < 0).
[...]
NumberNonPositive
BoundTypes.NumberNonPositive
— TypeNumberNonPositive{T<:Number} <: BoundNumber{T}
NumberNonPositive{T}(x::Number)
A number constraint that enforces x ≤ 0
for value x
of type T
.
Examples
julia> NumberNonPositive{Float64}(-10.0)
-10.0
julia> NumberNonPositive{Float64}(10.0)
ERROR: ConstraintError: constraints of type NumberNonPositive violated.
Wrong value: number 10.0 must be a negative or zero (x ≤ 0).
[...]
NumberNonNegative
BoundTypes.NumberNonNegative
— TypeNumberNonNegative{T<:Number} <: BoundNumber{T}
NumberNonNegative{T}(x::Number)
A number constraint that enforces x ≥ 0
for value x
of type T
.
Examples
julia> NumberNonNegative{Float64}(10.0)
10.0
julia> NumberNonNegative{Float64}(-10.0)
ERROR: ConstraintError: constraints of type NumberNonNegative violated.
Wrong value: -10.0 must be a positive or zero (x ≥ 0).
[...]
NumberGreater
BoundTypes.NumberGreater
— TypeNumberGreater{T<:Number,V} <: BoundNumber{T}
NumberGreater{T,V}(x::Number)
A number constraint that enforces x > V
for value x
of type T
.
Examples
julia> NumberGreater{Float64,10.0}(20.0)
20.0
julia> NumberGreater{Float64,10.0}(5.0)
ERROR: ConstraintError: constraints of type NumberGreater violated.
Wrong value: 5.0 must be greater than 10.0.
[...]
NumberGreaterOrEqual
BoundTypes.NumberGreaterOrEqual
— TypeNumberGreaterOrEqual{T<:Number,V} <: BoundNumber{T}
NumberGreaterOrEqual{T,V}(x::Number)
A number constraint that enforces x ≥ V
for value x
of type T
.
Examples
julia> NumberGreaterOrEqual{Float64,10.0}(20.0)
20.0
julia> NumberGreaterOrEqual{Float64,10.0}(5.0)
ERROR: ConstraintError: constraints of type NumberGreaterOrEqual violated.
Wrong value: 5.0 must be greater or equal than 10.0.
[...]
NumberLess
BoundTypes.NumberLess
— TypeNumberLess{T<:Number,V} <: BoundNumber{T}
NumberLess{T,V}(x::Number)
A number constraint that enforces x < V
for value x
of type T
.
Examples
julia> NumberLess{Float64,10.0}(5.0)
5.0
julia> NumberLess{Float64,10.0}(20.0)
ERROR: ConstraintError: constraints of type NumberLess violated.
Wrong value: 20.0 must be less than 10.0.
[...]
NumberLessOrEqual
BoundTypes.NumberLessOrEqual
— TypeNumberLessOrEqual{T<:Number,V} <: BoundNumber{T}
NumberLessOrEqual{T,V}(x::Number)
A number constraint that enforces x ≤ V
for value x
of type T
.
Examples
julia> NumberLessOrEqual{Float64,10.0}(5.0)
5.0
julia> NumberLessOrEqual{Float64,10.0}(20.0)
ERROR: ConstraintError: constraints of type NumberLessOrEqual violated.
Wrong value: 20.0 must be less or equal than 10.0.
[...]
NumberOdd
BoundTypes.NumberOdd
— TypeNumberOdd{T<:Number} <: BoundNumber{T}
NumberOdd{T}(x::Number)
A numeric constraint to ensure that the value x
of type T
is odd.
Examples
julia> NumberOdd{Float64}(5.0)
5.0
julia> NumberOdd{Float64}(4.0)
ERROR: ConstraintError: constraints of type NumberOdd violated.
Wrong value: 4.0 must be odd.
[...]
NumberEven
BoundTypes.NumberEven
— TypeNumberEven{T<:Number} <: BoundNumber{T}
NumberEven{T}(x::Number)
A numeric constraint to ensure that the value x
of type T
is even.
Examples
julia> NumberEven{Float64}(4.0)
4.0
julia> NumberEven{Float64}(5.0)
ERROR: ConstraintError: constraints of type NumberEven violated.
Wrong value: 5.0 must be even.
[...]
NumberInterval
BoundTypes.NumberInterval
— TypeNumberInterval{T<:Number,A,L,R,B} <: BoundNumber{T}
NumberInterval{T,A,L,R,B}(x::Number)
A numeric constraint for a value x
of type T
which belongs to an interval between A
and B
. Parameters L
and R
are the comparison functions e.g <
or <=
which determine whether interval boundaries are included.
Examples
julia> NumberInterval{Float64,5,<,<=,10}(7.0)
7.0
julia> NumberInterval{Float64,5,<,<=,10}(10.0)
10.0
julia> NumberInterval{Float64,5,<,<=,10}(15.0)
ERROR: ConstraintError: constraints of type NumberInterval violated.
Wrong value: 15.0 must be in interval between 5 and 10.
[...]