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.
| Key | Usage |
|---|---|
luhn | Card number (Amex 15 / others 16 digits) |
expiry | MMYY: month 1–12, not a past date |
tckn | 11-digit Turkish ID algorithm |
vkn | 10-digit tax ID number |
iban | TR + 24 digits, mod-97 |
email | Email regex |
url | URL regex |
date | Calendar 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.
