Skip to Content

Schema & Presets

The schema is the core configuration for ViraStack Mask. It maps your form field names to mask definitions.

Schema Definition

The schema type is MaskSchema<TFieldValues>, where keys match your form values. Values can be a preset name (string) or a MaskOptions object.

const { taxId, customCode } = useViraMask({ form, schema: { // Using a preset taxId: 'tckn', // Using custom options customCode: { mask: 'AA-999', transform: 'uppercase', }, }, });

Built-in Presets

ViraStack Mask includes presets for common use cases.

PresetMask / PatternDescription
card9999 9999 9999 9999Credit card number (Luhn validation). Auto-detects Amex (4-6-5 format).
expiry99/99Card expiry date
cvv999Card security code
tckn99999999999Turkish Identity Number (Algorithm validation)
phone(999) 999 99 99Turkey phone format
email/[a-zA-Z0-9@._-]/Email allowed chars
url/[a-zA-Z0-9@:%._\+~#=/?&-]/URL allowed chars
alpha/[a-zA-Z]/Alphabetic characters only
numeric/[0-9]/Numeric characters only
currencyCurrency optionsCurrency formatting
ibanTR99 ...IBAN format
date99/99/9999Date format
taxNumber9999999999Tax number (VKN algorithm validation)
zipCode99999Zip code
password-Password input type
text-Plain text

Overriding Presets

You can use a preset as a base and override specific options by spreading the preset configuration (if you access PRESETS) or simply defining the options you need manually.

Currently, the schema accepts either a string key or the full object. To “extend” a preset, you would typically just define the full object with the desired properties, as presets are just shorthand for specific MaskOptions.

See Also

  • Mask Options: Explore all available configuration options for customizing masks.
  • Examples: View live demos of various presets and custom configurations.

© 2026 ViraStack. MIT License.