Ready-made masks
Ready-made masks. Import them from tinyval-mask/presets so only the ones you use are bundled. All of them are also available via the masks object from tinyval-mask.
import { phone, card, money } from 'tinyval-mask/presets'; // tree-shakeable
import { masks } from 'tinyval-mask'; // masks.phone(), masks.card()…Phones
| Country | Mask | Format |
|---|---|---|
| 🇷🇺 Russia | phone(), phone('ru') | +7 (123) 456-78-90 |
| 🇰🇿 Kazakhstan | phone('kz') | +7 (123) 456-78-90 |
| 🇧🇾 Belarus | phone('by') | +375 (12) 345-67-89 |
| 🇺🇦 Ukraine | phone('ua') | +380 (12) 345-67-89 |
| 🇺🇿 Uzbekistan | phone('uz') | +998 (12) 345-67-89 |
| 🇰🇬 Kyrgyzstan | phone('kg') | +996 (123) 456-789 |
| 🇹🇯 Tajikistan | phone('tj') | +992 (12) 345-67-89 |
| 🇹🇲 Turkmenistan | phone('tm') | +993 (12) 34-56-78 |
| 🇦🇲 Armenia | phone('am') | +374 (12) 345-678 |
| 🇬🇪 Georgia | phone('ge') | +995 (123) 45-67-89 |
| 🇦🇿 Azerbaijan | phone('az') | +994 (12) 345-67-89 |
| 🇲🇩 Moldova | phone('md') | +373 (12) 345-678 |
| 🇱🇻 Latvia | phone('lv') | +371 1234-5678 |
| 🇱🇹 Lithuania | phone('lt') | +370 (123) 45678 |
| 🇪🇪 Estonia | phone('ee') | +372 123 4567 |
| 🇺🇸 United States | phone('us') | +1 (123) 456-7890 |
| 🇨🇦 Canada | phone('ca') | +1 (123) 456-7890 |
| 🇬🇧 United Kingdom | phone('gb') | +44 1234 567890 |
| 🇩🇪 Germany | phone('de') | +49 123 4567890 |
| 🇫🇷 France | phone('fr') | +33 1 23 45 67 89 |
| 🇮🇹 Italy | phone('it') | +39 123 456 7890 |
| 🇪🇸 Spain | phone('es') | +34 123 45 67 89 |
| 🇵🇱 Poland | phone('pl') | +48 123 456 789 |
| 🇹🇷 Türkiye | phone('tr') | +90 (123) 456 78 90 |
| 🇨🇳 China | phone('cn') | +86 123 4567 8901 |
| 🇮🇳 India | phone('in') | +91 12345 67890 |
| 🇮🇱 Israel | phone('il') | +972 12-345-6789 |
| 🇦🇪 United Arab Emirates | phone('ae') | +971 12 345 6789 |
Unmasked — all digits including the country code: +375 (29) 123-45-67 → 375291234567. For Russia and Kazakhstan a leading 7 or 8 is treated as the country code: 89991234567 → +7 (999) 123-45-67.
If the country isn't known in advance, use phoneAuto: the mask is chosen by the code the user types, with a flag and the country name for your UI.
Bank cards
| Mask | Example |
|---|---|
card() | 4276 1234 5678 9012; Amex — 3782 822463 10005; up to 19 digits |
cardExpiry() | 12/26 |
cvc() | 123 or 1234 |
cardBrand(number) | 'visa', 'mastercard', 'mir', 'amex', 'unionpay', 'unknown' — e.g. to show an icon |
Dates and time
| Mask | Example |
|---|---|
date(), date('dd.mm.yyyy') | 02.10.2026 |
date('yyyy-mm-dd'), date('mm/dd/yyyy'), date('dd/mm/yyyy') | 2026-10-02 |
time(), time(true) | 09:30, 09:30:15 |
datetime() | 02.10.2026 15:30 |
Impossible digits can't be typed: day 32, month 13, hour 25, minute 60, 00.00. cardExpiry does the same for the month. Whether the whole date exists (February 31) is checked by validation: coerce.date in tinyval.
Russian documents and bank details
| Mask | Example |
|---|---|
inn() | 7707083893 or 500100732259 (10 or 12 digits) |
snils() | 123-456-789 01 |
passport() | 45 10 123456 |
ogrn() | 13 or 15 digits |
bik() | 044525225 |
kpp() | 7743AB001 |
account() | 40702 810 9 0000 0000001 |
postcode() | 101000 |
carPlate() | А 123 ВС 77 — Latin look-alike letters are replaced with Cyrillic |
Numbers
| Mask | Example |
|---|---|
money({ currency: '₽' }) | 1 500,50 ₽ — unmasked 1500.50 |
percent() | 15 % |
They accept all numberMask options.
Other
| Mask | Example |
|---|---|
mac() | AA:BB:CC:DD:EE:FF |
hexColor() | #FF8800 |
What valid checks
isValid and the valid property mean the value is filled and correct. isComplete and complete mean only filled.
| Mask | valid |
|---|---|
date, datetime | The date exists: no 31.02, 29.02 only in a leap year |
cardExpiry | Month 01–12, not expired |
card | The check digit (Luhn algorithm) |
inn, snils, ogrn | Checksums |
phoneAuto | The number is filled by the mask of a detected country |
| others | The same as complete |
isComplete('31.02.2026', date()); // true — all digits are there
isValid('31.02.2026', date()); // false — no such dateSee also
- Patterns — your own mask if there is no ready-made one