FormWork FormWork

Validation Rules

Ensure data quality with custom validation rules.

Validation rules ensure that submitted data meets your requirements. Beyond built-in field validation, you can create custom rules with conditions and custom error messages.

Built-in Validation

Each field type has automatic validation:

Field TypeBuilt-in Validation
EmailValid email format
URLValid URL with protocol
NumberNumeric value within range
DateValid date format
PhoneContains digits
FileType and size limits

Custom Validation Rules

Add custom validation to any field:

  1. Select the field in the builder
  2. Go to the Validation tab
  3. Click Add Rule
  4. Configure the rule
  5. Save

Rule Structure

Each validation rule has:

  • Condition: When to show an error
  • Message: Error message to display

The rule triggers when the condition evaluates to true for an error state.

Creating Validation Rules

Simple Value Check

Validate the current field’s value:

Rule: length_lt → 10
Message: "Must be at least 10 characters"

Cross-Field Validation

Validate based on other fields:

Rule: "confirm_email" neq "email"
Message: "Email addresses must match"

Conditional Validation

Only validate when certain conditions are met:

IF "country" = "United States"
THEN validate "zip" matches pattern "^\d{5}(-\d{4})?$"
Message: "Please enter a valid US ZIP code"

Validation Operators

All conditional logic operators work for validation:

Text Validation

OperatorUse Case
matches_patternRegex validation
containsMust include substring
starts_withMust begin with prefix
ends_withMust end with suffix

Numeric Validation

OperatorUse Case
gt / gteMinimum value
lt / lteMaximum value
eq / neqExact value match

Length Validation

OperatorUse Case
length_gt / length_gteMinimum length
length_lt / length_lteMaximum length
length_eqExact length

Format Validation

OperatorUse Case
is_emailValid email
is_urlValid URL
is_numberNumeric value
is_integerWhole number
is_alphaLetters only
is_alphanumLetters and numbers

Error Messages

Writing Good Error Messages

  • Be specific about what’s wrong
  • Tell users how to fix it
  • Avoid technical jargon
  • Keep it brief

Good:

“Phone number must include area code (e.g., 555-123-4567)”

Bad:

“Invalid format”

Dynamic Error Messages

Include field values in messages using templates:

Message: "Value must be greater than {{ min_value }}"

When Validation Runs

Client-Side (Form Widget)

  • On field blur (when user leaves field)
  • On form submission attempt
  • Immediate feedback to users

Server-Side (Always)

  • When entry is created or updated
  • When workflows modify values
  • When entries are imported

Validation States

Entry Status

StatusMeaning
ValidAll rules pass
InvalidOne or more rules fail
PendingAsync validation in progress

Field Status

Each field shows:

  • Error message if invalid
  • Success indicator if valid (optional)
  • No indicator if untouched

Common Validation Patterns

Password Requirements

Rule 1: length_lt → 8
Message: "Password must be at least 8 characters"

Rule 2: not matches_pattern → "[A-Z]"
Message: "Password must include an uppercase letter"

Rule 3: not matches_pattern → "[0-9]"
Message: "Password must include a number"

Phone Number Format

Rule: not matches_pattern → "^\+?[\d\s-()]{10,}$"
Message: "Please enter a valid phone number"

Date Range

Rule: "end_date" lt "start_date"
Message: "End date must be after start date"

Unique Selection

For multiple selects or repeaters:

Rule: Check for duplicates
Message: "Each item must be unique"

Validation in Workflows

Workflows can also validate data:

On Submission

Trigger workflow on form submission to:

  • Run complex validation logic
  • Check against external data
  • Validate across multiple forms

Validation Step

Add a condition step that:

  • Checks validation rules
  • Updates entry status
  • Sends notifications for invalid data

Best Practices

Layer Your Validation

  1. Field-level for basic format
  2. Custom rules for business logic
  3. Workflow for complex validation

Be User-Friendly

  • Validate early and often
  • Show all errors at once
  • Allow submission to save drafts

Test Edge Cases

  • Empty values
  • Boundary values (min/max)
  • Special characters
  • Very long inputs

Performance

  • Avoid expensive regex patterns
  • Limit cross-field validations
  • Consider async validation for heavy checks