Ivandt logo

Specialised validators

Specialised validators

phone

Validates that a field contains a properly formatted phone number using libphonenumber-js.

PropertyTypeRequiredDefaultDescription
countriesCountryCode[]Yes-List of country codes to validate against (e.g., ['US', 'CA'])
withInternationalCodebooleanNofalseWhether 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.

PropertyTypeRequiredDefaultDescription
parsePatternsstring[]No[formatPattern, ISO_8601]Array of Moment.js format patterns to try when parsing
formatPatternstringYes-Moment.js format string for output
strictParsingbooleanNotrueWhether 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.

PropertyTypeRequiredDescription
version'1' | '3' | '4' | '5' | '6' | '7'YesUUID 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.

PropertyTypeRequiredDescription
providersstring[]NoOptional 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.

PropertyTypeRequiredDescription
allowedLabelsstring[]YesList 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 acceptNewValueIfNoOptions setting