string
Accepts and returns strings.Example
nonEmptyString
Likestring, but will reject the empty string or strings containing only whitespace.
Example
regex
Accepts and returns strings that match the given regular expression.Parameters
regex- The regular expression pattern to match againstmsg- Error message to display when the string doesn’t match
Example
startsWith
Accepts and returns strings that start with the given prefix.Parameters
prefix- The required string prefix
Example
endsWith
Accepts and returns strings that end with the given suffix.Parameters
suffix- The required string suffix
Example
Example
urlString
Accepts strings that are valid URLs.Example
url
Accepts strings that are valid URLs, returns the value as a URL instance.Example
httpsUrl
Accepts strings that are valid URLs, but only HTTPS ones. Returns the value as a URL instance.Example
identifier
Accepts and returns strings that are valid identifiers in most programming languages.Example
nanoid
Accepts and returns nanoid string values. It assumes the default nanoid alphabet. If you’re using a custom alphabet, useregex() instead.
Parameters
options- Optional size constraints (defaults to{ size: 21 })
Example
uuid
Accepts strings that are valid UUIDs (universally unique identifier).Example
uuidv1
Likeuuid, but only accepts UUIDv1 strings.
Example
uuidv4
Likeuuid, but only accepts UUIDv4 strings.
Example
decimal
Accepts and returns strings with decimal digits only (base-10). To convert these to numbers, use thenumeric decoder.
Example
hexadecimal
Accepts and returns strings with hexadecimal digits only (base-16).Example
numeric
Accepts valid numerical strings (in base-10) and returns them as a number. To only accept numerical strings and keep them as string values, use thedecimal decoder.
