Skip to content

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.

ts
import { phone, card, money } from 'tinyval-mask/presets'; // tree-shakeable
import { masks } from 'tinyval-mask';                      // masks.phone(), masks.card()…

Phones ​

CountryMaskFormat
🇷🇺 Russiaphone(), phone('ru')+7 (123) 456-78-90
🇰🇿 Kazakhstanphone('kz')+7 (123) 456-78-90
🇧🇾 Belarusphone('by')+375 (12) 345-67-89
🇺🇦 Ukrainephone('ua')+380 (12) 345-67-89
🇺🇿 Uzbekistanphone('uz')+998 (12) 345-67-89
🇰🇬 Kyrgyzstanphone('kg')+996 (123) 456-789
🇹🇯 Tajikistanphone('tj')+992 (12) 345-67-89
🇹🇲 Turkmenistanphone('tm')+993 (12) 34-56-78
🇦🇲 Armeniaphone('am')+374 (12) 345-678
🇬🇪 Georgiaphone('ge')+995 (123) 45-67-89
🇦🇿 Azerbaijanphone('az')+994 (12) 345-67-89
🇲🇩 Moldovaphone('md')+373 (12) 345-678
🇱🇻 Latviaphone('lv')+371 1234-5678
🇱🇹 Lithuaniaphone('lt')+370 (123) 45678
🇪🇪 Estoniaphone('ee')+372 123 4567
🇺🇸 United Statesphone('us')+1 (123) 456-7890
🇨🇦 Canadaphone('ca')+1 (123) 456-7890
🇬🇧 United Kingdomphone('gb')+44 1234 567890
🇩🇪 Germanyphone('de')+49 123 4567890
🇫🇷 Francephone('fr')+33 1 23 45 67 89
🇮🇹 Italyphone('it')+39 123 456 7890
🇪🇸 Spainphone('es')+34 123 45 67 89
🇵🇱 Polandphone('pl')+48 123 456 789
🇹🇷 Türkiyephone('tr')+90 (123) 456 78 90
🇨🇳 Chinaphone('cn')+86 123 4567 8901
🇮🇳 Indiaphone('in')+91 12345 67890
🇮🇱 Israelphone('il')+972 12-345-6789
🇦🇪 United Arab Emiratesphone('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 ​

MaskExample
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 ​

MaskExample
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 ​

MaskExample
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 ​

MaskExample
money({ currency: '₽' })1 500,50 ₽ — unmasked 1500.50
percent()15 %

They accept all numberMask options.

Other ​

MaskExample
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.

Maskvalid
date, datetimeThe date exists: no 31.02, 29.02 only in a leap year
cardExpiryMonth 01–12, not expired
cardThe check digit (Luhn algorithm)
inn, snils, ogrnChecksums
phoneAutoThe number is filled by the mask of a detected country
othersThe same as complete
ts
isComplete('31.02.2026', date()); // true — all digits are there
isValid('31.02.2026', date());    // false — no such date

See also ​

  • Patterns — your own mask if there is no ready-made one