Primitives
string
A full list of string keywords can be found here.
literals
patterns
Regex literals specify an unanchored regular expression that an input string must match.
They can either be string-embedded or refer directly to a RegExp
instance.
lengths
Constrain a string with an inclusive or exclusive min or max length.
Range expressions allow you to specify both a min and max length and use the same syntax for exclusivity.
number
A full list of number keywords can be found here.
literals
ranges
Constrain a number with an inclusive or exclusive min or max.
Range expressions allow you to specify both a min and max and use the same syntax for exclusivity.
divisors
Constrain a number
to a multiple of the specified integer.
bigint
To allow any bigint
value, use the "bigint"
keyword.
literals
To require an exact bigint
value in your type, you can use add the suffix n
to a string-embedded number literal to make it a bigint
.
You may also use a unit expression to define bigint
literals.
symbol
To allow any symbol
value, use the "symbol"
keyword.
To reference a specific symbol in your definition, use a unit expression.
No special syntax is required to define symbolic properties like { [mySymbol]: "string" }
. For more information and examples of how to combine symbolic keys with other syntax like optionality, see properties.
boolean
To allow true
or false
, use the "boolean"
keyword.
literals
To require a specific boolean value, use the corresponding literal.
null
The "null"
keyword can be used to allow the exact value null
, generally as part of a union.
undefined
The "undefined"
keyword can be used to allow the exact value undefined
, generally as part of a union.
Allowing undefined as a value does not make the key optional!
In TypeScript, a required property that allows undefined
must still be present for the type to be satisfied.
The same is true in ArkType.