ViraStack
  • About
  • Support
HomeGet StartedExamples

Getting started

  • Introduction
  • llms.txt
  • llms-full.txt

Usage

  • useViraMask()
  • Custom mask
  • Validation
  • Helpers
  • Types
  • UI libraries

Validation

Built-in validators on presets or your own function; wired to React Hook Form errors.

Built-in validators

Enable with validate: true and a validator key. Empty fields are not validated.

KeyUsage
luhnCard number (Amex 15 / others 16 digits)
expiryMMYY: month 1–12, not a past date
tckn11-digit Turkish ID algorithm
vkn10-digit tax ID number
ibanTR + 24 digits, mod-97
emailEmail regex
urlURL regex
dateCalendar date (with dateFormat)

Functions can also be imported directly: validateLuhn, validateTCKN, validateIBAN, the VALIDATORS map, etc.

Custom validator

{
  mask: "(999) 999 99 99",
  validate: true,
  validator: (value) => value.length === 10,
}

Error message

On failed validation, errorMessage is returned; otherwise RHF gets false. Read errors from form.formState.errors.

For type definitions see types; for live examples see examples.

PreviousCustom maskNextHelpers

On this page

  • Built-in validators
  • Custom validator
  • Error message
Something wrong? Fix it