applyMask

Mask
stable

Apply a character-based mask pattern to a raw string value. Returns both the masked display string and the unmasked raw string, plus a flag indicating whether all consumer slots are filled.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

value
required
string
The raw input string to format. Leading/trailing whitespace is preserved.
pattern
required
string
The mask pattern string. Literal characters are emitted as-is; token characters consume one character from the input.

API

Return value

The value returned by this util.

An object { masked: string, unmasked: string, complete: boolean }. "complete" is true when every consumer token in the pattern has been filled.

Usage

Examples

Ready-to-paste usage snippets.

Phone number mask

typescript