Skip to content

Validation rules

Steps for

How it works

Validation stops incorrect data reaching your team, workflows and store. It works in layers, and the first two need no code:

Layers of validation

Built-in checks

Format checks for each field type, with no setup.
(this flows forward)

Custom rules

Your business rules, such as a minimum length or matching values.
(this flows forward)

Workflows

Advanced checks, such as against an external system.

Built-in checks

Each field type checks its own format, with no setup:

Field typeBuilt-in check
EmailA valid email structure.
URLA valid web address.
NumberA number within range.
DateA valid date.
PhoneValid digits.
File uploadFile type and size limits.

To make a field mandatory, tick Required on the field's Properties tab.

Add a validation rule

Add a custom rule when the built-in checks aren't enough, for example to require a minimum length.

  1. In the form builder, select the field.
  2. In Configure field, open the Validation tab.
  3. Click Add rule.
  4. Set the Condition: the values you want to allow.
  5. Enter the Error message customers see when the condition isn't met.

Changes save to your draft automatically.

Describe what's allowed, not what's blocked

A rule's error message shows when its condition is false, not when it matches. Say you don't ship to the United Kingdom. Don't set the condition to "country equals United Kingdom": that shows the error for every other country. Instead, set it to the countries you do ship to, such as "country is one of France, Germany, Spain". The error then only shows for a country outside that list.

Types of rule

A rule can check a field on its own, or against other data:

TypeWhat it checksExamples
Simple value rulesA field's own answer."Must be at least 10 characters", for password strength, reference numbers and minimum input.
Cross-field and data reference rulesAn answer against another field, or against other data through data references.The confirmation email matches the email; the end date is after the start date; a purchase ID matches one of the customer's SparkLayer purchases.

Operators

Validation uses the same operators as conditional logic. Which ones you can choose depends on the type of field.

Every operator
OperatorExample use
Matches patternA regular expression (regex) format check.
ContainsMust include a value.
Starts withA required prefix.
Ends withA required suffix.
Greater than / equalA minimum quantity.
Less than / equalA maximum value.
Equals / not equalsAn exact match.
Minimum lengthPassword rules.
Maximum lengthReference codes.
Exact lengthPostcodes or IDs.
Is emailAn email format check.
Is numberA numeric value.
Is integerA whole number.
Is alpha / alphanumericLetters only, or letters and numbers.

Common patterns include making sure an end date is after a start date, and preventing duplicate items in a repeatable group or multi-select field.

Write error messages

A good error message says what's wrong and how to fix it, in plain words. For example, write "Phone number must include area code", not "Invalid input". Messages can include values through templates, such as the required minimum.

Validation states

A form can only be submitted when every rule passes.

The three validation states
StateWhat it means
ValidAll rules pass. The form can be submitted.
InvalidOne or more rules fail. The form can't be submitted.
PendingA check is still running. The form can't be submitted yet.

Before a customer interacts with a field, it shows no indicator. After that, it shows an error message when invalid, and optionally a success indicator.

Validate with workflows

For checks the form can't do itself, use workflows. A workflow can run on submission, a page change or an answer update. It can run advanced checks, validate against external systems and apply logic across forms. Inside a workflow, Condition steps can update answers, notify your team about invalid data or start follow-up actions.

Tips

  • Layer your validation: built-in checks for format, custom rules for business logic, and workflows for advanced checks.
  • Validate early rather than only on submit, show clear instructions, and avoid overly strict rules.
  • Test empty values, the minimum and maximum, special characters and very long answers.
  • Keep forms fast: avoid heavy regular expressions and complex cross-field rules where you can, and use workflows for advanced processing.
Was this page helpful?

Last updated