RegExp
.empty
empty
enforces that a string
, array
, map
, or set
is empty.🤖 Technically this is the same as usingsize
of zero, but "empty" feels slightly nicer and will give a slightly easier to read error.
max
max
enforces that a number
struct is less than a threshold.🤖 If you need an exclusive maxmimum you can pass{ exclusive: true }
as the third argument, likemax(number(), 0, { exclusive: true })
for negative numbers.
min
min
enforces that a number
struct is greater than a threshold.🤖 If you need an exclusive minimum you can pass{ exclusive: true }
as the third argument, likemin(number(), 0, { exclusive: true })
for positive numbers.
nonempty
nonempty
enforces that a string, array, map, or set is not empty. This does the opposite of empty
.pattern
pattern
enforces that a string
struct also matches a supplied RegExp
.size
size
enforces that a number
, string
, array
, map
, or set
struct also is within a certain min
and max
size (or length).🤖 Themax
argument is optional and defaults to whatever you pass formin
, which makes specifying exact sizes easy (just omit the max).
number
type at compile time.