Mask
Apply a generic digit-based input mask
Mask
The mask formatter applies a generic mask where the # placeholder consumes digits only.
Options
| Option | Type | Default | Description |
|---|---|---|---|
mask | string | — | The mask, e.g. "###-###-####". |
maskChar | string | "#" | The placeholder character that consumes digits. |
Usage
validationSchema: {
code: { format: { type: "mask", options: { mask: "AAA-####", maskChar: "A" } } },
}Results
| Mask | Typed | Result |
|---|---|---|
###-###-#### | 5551234567 | 555-123-4567 |
AAA-#### | ABC1234 | ABC-1234 |
Things to know
#in a mask consumes digits; any othermaskCharconsumes alphanumeric characters (for TINs and reference numbers).- For tax identifiers, prefer the dedicated tin formatter.