Skip to content

Function: Regex()

ts
function 
Regex
(
pattern
,
description
?):
TypeFunction
<string>;

Defined in: packages/advanced-types/src/index.ts:74

Creates a regex type function that validates the input against the provided pattern.

Parameters

ParameterTypeDescription

pattern

RegExp

The regular expression pattern to validate against

description?

string

Optional description for display purposes

Returns

TypeFunction<string>

A TypeFunction that validates the input value

Throws

If the value does not match the regex pattern

Released under the MIT license