Primitives
string
keywords
The following keywords can be referenced in any definition, e.g.:
Alias | Description |
---|---|
string | a string |
string.alpha | only letters |
string.alphanumeric | only letters and digits 0-9 |
string.base64 | base64-encoded |
string.base64.url | base64url-encoded |
string.capitalize | a morph from a string to capitalized |
string.capitalize.preformatted | capitalized |
string.creditCard | a credit card number and a credit card number |
string.date | a string and a parsable date |
string.date.epoch | an integer string representing a safe Unix timestamp |
string.date.epoch.parse | a morph from an integer string representing a safe Unix timestamp to a Date |
string.date.iso | an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date |
string.date.iso.parse | a morph from an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date to a Date |
string.date.parse | a morph from a string and a parsable date to a Date |
string.digits | only digits 0-9 |
string.email | an email address |
string.hex | hex characters only |
string.integer | a well-formed integer string |
string.integer.parse | a morph from a well-formed integer string to an integer |
string.ip | an IP address |
string.ip.v4 | an IPv4 address |
string.ip.v6 | an IPv6 address |
string.json | a JSON string |
string.json.parse | safe JSON string parser |
string.lower | a morph from a string to only lowercase letters |
string.lower.preformatted | only lowercase letters |
string.normalize | a morph from a string to NFC-normalized unicode |
string.normalize.NFC | a morph from a string to NFC-normalized unicode |
string.normalize.NFC.preformatted | NFC-normalized unicode |
string.normalize.NFD | a morph from a string to NFD-normalized unicode |
string.normalize.NFD.preformatted | NFD-normalized unicode |
string.normalize.NFKC | a morph from a string to NFKC-normalized unicode |
string.normalize.NFKC.preformatted | NFKC-normalized unicode |
string.normalize.NFKD | a morph from a string to NFKD-normalized unicode |
string.normalize.NFKD.preformatted | NFKD-normalized unicode |
string.numeric | a well-formed numeric string |
string.numeric.parse | a morph from a well-formed numeric string to a number |
string.semver | a semantic version (see https://semver.org/) |
string.trim | a morph from a string to trimmed |
string.trim.preformatted | trimmed |
string.upper | a morph from a string to only uppercase letters |
string.upper.preformatted | only uppercase letters |
string.url | a string and a URL string |
string.url.parse | a morph from a string and a URL string to a URL instance |
string.uuid | a UUID |
string.uuid.v1 | a UUIDv1 |
string.uuid.v2 | a UUIDv2 |
string.uuid.v3 | a UUIDv3 |
string.uuid.v4 | a UUIDv4 |
string.uuid.v5 | a UUIDv5 |
string.uuid.v6 | a UUIDv6 |
string.uuid.v7 | a UUIDv7 |
string.uuid.v8 | a UUIDv8 |
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
keywords
The following keywords can be referenced in any definition, e.g.:
Alias | Description |
---|---|
number | a number |
number.Infinity | Infinity |
number.NaN | NaN |
number.NegativeInfinity | -Infinity |
number.epoch | an integer representing a safe Unix timestamp |
number.integer | an integer |
number.safe | at least -9007199254740991 and at most 9007199254740991 |
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.