Specialised validators
Specialised validators
phone
Validates that a field contains a properly formatted phone number using libphonenumber-js.
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
countries | CountryCode[] | Yes | - | List of country codes to validate against (e.g., ['US', 'CA']) |
withInternationalCode | boolean | No | false | Whether to require '+' prefix |
{
type: 'phone',
countries: ['US', 'CA'],
withInternationalCode: true,
message: 'Invalid phone number format'
}Behavior:
- Numbers with '+' are parsed as international format
- Numbers without '+' are tried against each allowed country
- Parsing is strict (no extraction from surrounding text)
date
Validates that a field contains a properly formatted date using Moment.js.
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
parsePatterns | string[] | No | [formatPattern, ISO_8601] | Array of Moment.js format patterns to try when parsing |
formatPattern | string | Yes | - | Moment.js format string for output |
strictParsing | boolean | No | true | Whether to use strict parsing mode |
{
type: 'date',
parsePatterns: ['YYYY-MM-DD', 'MM/DD/YYYY'],
formatPattern: 'YYYY-MM-DD',
strictParsing: true
}Note: Always accepts null, boolean, number, and Date objects as valid.
uuid
Validates that a field contains a properly formatted UUID according to the specified version.
| Property | Type | Required | Description |
|---|---|---|---|
version | '1' | '3' | '4' | '5' | '6' | '7' | Yes | UUID version to validate |
{
type: 'uuid',
version: '4',
message: 'Invalid UUID format'
}creditcard
Validates that a field contains a valid credit card number using the Luhn algorithm.
| Property | Type | Required | Description |
|---|---|---|---|
providers | string[] | No | Optional list of accepted card providers (e.g., ['visa', 'mastercard', 'amex']). When specified, card must match at least one provider |
{
type: 'creditcard',
providers: ['visa', 'mastercard', 'amex'],
message: 'Invalid credit card number'
}enumerate
Validates that a field value matches one of a predefined set of allowed values.
| Property | Type | Required | Description |
|---|---|---|---|
allowedLabels | string[] | Yes | List of allowed values (resolved dynamically from data sources) |
{
type: 'enumerate',
allowedLabels: ['Active', 'Inactive', 'Pending'],
message: 'Status must be Active, Inactive, or Pending'
}Behavior:
- For menu fields with no options, validation depends on
acceptNewValueIfNoOptionssetting