Validation rules
How it works
Validation stops incorrect data reaching your team, workflows and store. It works in layers, and the first two need no code:
Built-in checks
Custom rules
Workflows
Built-in checks
Each field type checks its own format, with no setup:
| Field type | Built-in check |
|---|---|
| A valid email structure. | |
| URL | A valid web address. |
| Number | A number within range. |
| Date | A valid date. |
| Phone | Valid digits. |
| File upload | File 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.
- In the form builder, select the field.
- In Configure field, open the Validation tab.
- Click Add rule.
- Set the Condition: the values you want to allow.
- 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:
| Type | What it checks | Examples |
|---|---|---|
| Simple value rules | A field's own answer. | "Must be at least 10 characters", for password strength, reference numbers and minimum input. |
| Cross-field and data reference rules | An 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
| Operator | Example use |
|---|---|
| Matches pattern | A regular expression (regex) format check. |
| Contains | Must include a value. |
| Starts with | A required prefix. |
| Ends with | A required suffix. |
| Greater than / equal | A minimum quantity. |
| Less than / equal | A maximum value. |
| Equals / not equals | An exact match. |
| Minimum length | Password rules. |
| Maximum length | Reference codes. |
| Exact length | Postcodes or IDs. |
| Is email | An email format check. |
| Is number | A numeric value. |
| Is integer | A whole number. |
| Is alpha / alphanumeric | Letters 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
| State | What it means |
|---|---|
| Valid | All rules pass. The form can be submitted. |
| Invalid | One or more rules fail. The form can't be submitted. |
| Pending | A 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.
Last updated