Defines a new string-struct matching a regular expression.
const EthAddressStruct = definePattern('EthAddress', /^0x[0-9a-f]{40}$/iu); type EthAddress = Infer; // string
const CaipChainIdStruct = defineTypedPattern<${string}:${string}>( 'CaipChainId', /^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}$/u; ); type CaipChainId = Infer; // ${string}:${string}
${string}:${string}
A new string-struct that matches the given pattern.
The pattern type, defaults to string.
string
Type name.
Regular expression to match.
Defines a new string-struct matching a regular expression.
Example
const EthAddressStruct = definePattern('EthAddress', /^0x[0-9a-f]{40}$/iu); type EthAddress = Infer; // string
const CaipChainIdStruct = defineTypedPattern<; //
${string}:${string}
>( 'CaipChainId', /^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}$/u; ); type CaipChainId = Infer${string}:${string}
Returns
A new string-struct that matches the given pattern.