BoundString
BoundTypes.BoundString — TypeBoundString{T<:AbstractString} <: AbstractStringAbstract type for string constraints.
StringCustomBound
BoundTypes.StringCustomBound — TypeStringCustomBound{T<:AbstractString,B} <: BoundString{T}
StringCustomBound{T,B}(x::AbstractString)A string 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> StringCustomBound{String,x -> length(x) > 5}("abcdef")
"abcdef"
julia> StringCustomBound{String,x -> length(x) > 5}("abc")
ERROR: ConstraintError: constraints of type StringCustomBound violated.
Wrong value: Custom constraint '#5' violated for value "abc" of type String.
[...]StringLowerCase
BoundTypes.StringLowerCase — TypeStringLowerCase{T<:AbstractString} <: BoundString{T}
StringLowerCase{T}(x::AbstractString)A string constraint for a value x of type T which characters must be in lowercase.
Examples
julia> StringLowerCase{String}("abcdef")
"abcdef"
julia> StringLowerCase{String}("aBcdEf")
ERROR: ConstraintError: constraints of type StringLowerCase violated.
Wrong value: some characters of "aBcdEf" must be in lowercase (B,E).
[...]StringUpperCase
BoundTypes.StringUpperCase — TypeStringUpperCase{T<:AbstractString} <: BoundString{T}
StringUpperCase{T}(x::AbstractString)A string constraint for a value x of type T which characters must be in uppercase.
Examples
julia> StringUpperCase{String}("ABCDEF")
"ABCDEF"
julia> StringUpperCase{String}("AbCDeF")
ERROR: ConstraintError: constraints of type StringUpperCase violated.
Wrong value: some characters of "AbCDeF" must be in uppercase (b,e).
[...]StringMinLength
BoundTypes.StringMinLength — TypeStringMinLength{T<:AbstractString,V} <: BoundString{T}
StringMinLength{T,V}(x::AbstractString)A string constraint for a value x of type T which length must be at least V characters.
Examples
julia> StringMinLength{String,5}("abcdef")
"abcdef"
julia> StringMinLength{String,5}("abc")
ERROR: ConstraintError: constraints of type StringMinLength violated.
Wrong value: length of the "abc" must be at least 5 characters (3).
[...]StringMaxLength
BoundTypes.StringMaxLength — TypeStringMaxLength{T<:AbstractString,V} <: BoundString{T}
StringMaxLength{T,V}(x::AbstractString)A string constraint for a value x of type T which length must be no more than V characters.
Examples
julia> StringMaxLength{String,5}("abc")
"abc"
julia> StringMaxLength{String,5}("abcdef")
ERROR: ConstraintError: constraints of type StringMaxLength violated.
Wrong value: length of the "abcdef" must be no more than 5 characters (6).
[...]StringFixedLength
BoundTypes.StringFixedLength — TypeStringFixedLength{T<:AbstractString,V} <: BoundString{T}
StringFixedLength{T,V}(x::AbstractString)A string constraint for a value x of type T which length must be equal to V characters.
Examples
julia> StringFixedLength{String,5}("abcde")
"abcde"
julia> StringFixedLength{String,5}("abc")
ERROR: ConstraintError: constraints of type StringFixedLength violated.
Wrong value: length of the "abc" must be equal to 5 characters (3).
[...]StringPattern
BoundTypes.StringPattern — TypeStringPattern{T<:AbstractString,P} <: BoundString{T}
StringPattern{T,P}(x::AbstractString)A string constraint for a value x of type T which must match regex pattern P.
Use a helper function @pattern_str to pass a regex expression.
Examples
julia> StringPattern{String,pattern"^[a-zA-Z0-9_]+$"}("abcde")
"abcde"
julia> StringPattern{String,pattern"^[a-zA-Z0-9_]+$"}("abc+def")
ERROR: ConstraintError: constraints of type StringPattern violated.
Wrong value: "abc+def" must match to regex pattern /^[a-zA-Z0-9_]+$/.
[...]BoundTypes.@pattern_str — Macro@pattern_str -> SymbolAn auxiliary function that allows you to pass a regex string to StringPattern parameters, turning it into a Symbol.