Custom mask (order number)
Write your own pattern: a letter, 9 digit; literals like - are display only.
Preview
Form value: -
Display: -
Details
- Pattern:
aa-9999 - Form value:
"AB1234" - Error keys:
orderNo.incomplete - transform: "uppercase" turns letters into capitals.
- The error key comes from the preset name: orderNo.incomplete.
Customization
Sharing with definePreset
Define it once; the hook, the server and tests use the same mask.
// masks.ts — shared by the client and the server
import { definePreset } from "@virastack/mask/server"
export const orderNo = definePreset("orderNo", {
mask: "aa-9999",
transform: "uppercase",
})
// form
useViraMask(form, { orderNo })For the hook API see useViraMask(); for your own pattern see custom mask.