Skip to content
Field Validation

Form Logic

Field Validation

Configure validation rules to ensure data quality and guide respondents.

Overview

Every field can have validation rules that are checked when the user attempts to advance (in multi-step forms) or submit the form. Invalid fields display an error message below them and are highlighted in red. Validation rules are defined in the validation object inside each field definition.

Built-in Rules

PropertyTypeDefaultDescription
requiredbooleanfalseField must have a non-empty value.
validation.minLengthnumber—Minimum character count for text fields.
validation.maxLengthnumber—Maximum character count for text fields.
validation.minnumber—Minimum value for number/range fields.
validation.maxnumber—Maximum value for number/range fields.
validation.patternstring—Regex the value must match.
validation.emailboolean—Validate as a valid email address format.
validation.urlboolean—Validate as a valid URL format.

Custom Error Messages

Every validation rule can have a companion message property to replace the default error text:

JSON
"validation": {
  "minLength": 8,
  "minLengthMessage": "Password must be at least 8 characters",
  "pattern": "^(?=.*[A-Z])(?=.*[0-9])",
  "patternMessage": "Must contain at least one uppercase letter and one number"
}

Regex Patterns

The validation.pattern property accepts any JavaScript-compatible regular expression string. Common patterns:

JSON
// Nepali postal code
"^\d{5}$"

// Alphanumeric only (no spaces)
"^[a-zA-Z0-9]+$"

// Strong password
"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$"

// URL slug
"^[a-z0-9]+(?:-[a-z0-9]+)*$"

Was this helpful?