form logicvalidation

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.minLengthnumberMinimum character count for text fields.
validation.maxLengthnumberMaximum character count for text fields.
validation.minnumberMinimum value for number/range fields.
validation.maxnumberMaximum value for number/range fields.
validation.patternstringRegex the value must match.
validation.emailbooleanValidate as a valid email address format.
validation.urlbooleanValidate as a valid URL format.

Custom Error Messages

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

"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:

// 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]+)*$"