FieldValidationRules
Defines the comprehensive set of validation rules that can be applied to form fields. This interface outlines all available validation types that can be configured for each field in the form. Each validation type accepts a ValidationRule containing both the validation criteria and an optional custom error message.
Props
The following table outlines the props for the FieldValidationRules:
| Name | Type | Default | Description |
|---|---|---|---|
| creditCard | - | Validates that the input is a valid credit card number. Checks length (13-16 digits) and applies Luhn algorithm validation. | |
| customValidator | (value: FormValueType) => string | null | - | Allows for completely custom validation logic as a function. This function receives the field value and should return either:
|
| date | - | Validates that the input can be parsed as a valid date. Uses Date.parse() to validate the string can be converted to a date. | |
| dateIso | - | Validates that the input follows ISO date format (YYYY-MM-DD). Ensures strict compliance with the ISO date standard. | |
| digits | - | Validates that the input contains only numeric digits (0-9). Rejects inputs containing decimal points, signs, letter characters or spaces. | |
- | Validates that the input conforms to a standard email address format. Checks for proper formatting with @ symbol and domain structure. | ||
| equalTo | - | Validates that the field's value exactly matches another field's value. Takes the name of another field as the first parameter. | |
| max | - | Validates that a numeric value doesn't exceed the specified maximum. Takes a number as the first parameter in the validation rule. | |
| maxLength | - | Validates that a string doesn't exceed the specified maximum length. Takes a number as the first parameter in the validation rule. | |
| min | - | Validates that a numeric value is at least the specified minimum. Takes a number as the first parameter in the validation rule. | |
| minLength | - | Validates that a string has at least the specified minimum length. Takes a number as the first parameter in the validation rule. | |
| number | - | Validates that the input contains a valid numeric value. Ensures the field can be converted to a number without errors. | |
| range | - | Validates that a numeric value falls within the specified range. Takes an array of two numbers [min, max] as the first parameter. | |
| rangeLength | - | Validates that a string's length falls within the specified range. Takes an array of two numbers [min, max] as the first parameter. | |
| regex | - | Validates that the input matches the specified regular expression pattern. Takes a RegExp object or a string pattern as the first parameter. | |
| required | - | Validates that the field has a non-empty value. When configured with [true], the field cannot be empty, null, or undefined. | |
| tel | - | Validates that the input conforms to a standard telephone number format. Checks for proper formatting of phone numbers with optional country code. | |
| url | - | Validates that the input is a properly formatted URL. Checks for proper protocol, domain structure, and path format. |