- ViraStack Mask
v2.4.0Minor
`getMaskPlaceholder()` and detailed IBAN error keys
Build placeholder text from a mask, and learn why an IBAN fails: country, length or checksum.
What changed
getMaskPlaceholder(spec): Returns placeholder text from a mask:(___) ___ __ __for{ preset: "phone", country: "TR" },TR__ ____ ____ ____ ____ ____ __for the Turkish IBAN. It takes whatcreateMasktakes, so you can pass the same schema entry you giveuseViraMask. On the root and/serverentries.- What it draws: Every character to type is
_. Separators and{fixed}parts stay as they are, optional[...]parts are left out. A mask that picks its pattern at runtime (card,cvv,plate) is read as it is for an empty field. - Where it returns
undefined: Number, currency and date masks (expiryincluded), an unknown preset, and a mask with at most one required character, such asfullName. - IBAN error keys: The
ibanpreset now names the reason.iban.country: the value does not start with two A–Z letters.iban.length: not the length of its country (26 for TR, 22 for DE).iban.checksum: the mod-97 check fails.{ preset: "iban", country: "TR" }fixes the country and the length, so of the new keys it only returnsiban.checksum. iban.invalidis the fallback: It stays for a character an IBAN cannot have (a letter outside A–Z) and for your ownvalidatethat returnsfalse.isValidIBANgives the same answers as before.- Size: The root entry goes from 9.95 kB to 10.07 kB (min+brotli).
Why
- Placeholder: A hand-written placeholder drifts from the mask: change the pattern and the hint under it stays the old one. The helper reads the same mask the field uses.
- IBAN keys: One "invalid IBAN" message does not tell the user what to fix. A missing digit and a mistyped digit need different messages.
- Limits: A country code the IBAN registry does not list is not rejected; it is checked with 15–34 characters and mod-97. National account rules (BBAN) are not checked. The hook does not set the placeholder on its own. We ran the tests in Chromium, Firefox and WebKit and in a Next.js app; we did not try other frameworks.
Commits
Migration
If your messages map has iban.invalid, add the three new keys. A wrong check digit used to return iban.invalid and now returns iban.checksum; without a message for it the user sees the raw key. Add iban.country, iban.length and iban.checksum, or fall back to your iban.invalid message for any other key that starts with iban.. A preset of your own that spreads presets.iban.options also gets the iban.* keys instead of <name>.invalid. Nothing else changes.