TYML lets you add additional constraints to types.
port: int @value 100..<200
@value
Attribute🔗Available for numeric types: int
, uint
, or float
.
setting: int @value 0..<100
You can specify ranges like 0..<100
. The forms are:
start..<end
: start inclusive, end exclusivestart..=end
: start inclusive, end inclusivestart..
: start inclusive, no upper bound..<end
: end exclusive, no lower bound..=end
: end inclusive, no lower bound@length
Attribute🔗Restrict the number of Unicode characters of a string
.
setting: string @length 0..<100
Range notation is the same as for @value
.
@u8size
Attribute🔗Restrict the UTF‑8 byte length of a string
.
setting: string @u8size 0..<100
Range notation is the same as for @value
.
@regex
Attribute🔗Restrict a string
by a regular expression.
// Single quotes avoid escaping
setting: string @regex '^\\d+$'
Use and
and or
to combine constraints.
// "and" has higher precedence.
// Use () to adjust precedence.
setting: string (@length 0..<10 or @length 100..<200) and @regex '^\\d+$'