FormWork documentation
Validation Rules
Combine built-in field constraints with typed custom rules and messages.
Validation prevents invalid entries from being submitted. Use built-in field settings first; add custom rules for business checks they cannot express.
Three layers
- Required — the visible field must have a value.
- Type configuration — email format, numeric bounds, file limits, password strength, choice count, and other options from Field Settings.
- Custom validation rules — operator-based rules in the field’s Validation panel.
Add a rule
- Select an answer field and open Validation.
- Select Add First Rule or Add Validation Rule.
- Choose a condition, such as Must be greater or equal to.
- Enter a fixed value or select a compatible reference.
- Optionally write a respondent-facing error message.
Each added rule must pass. Validation rules are not grouped with ANY/ALL controls; they are a list of requirements for that field.
Compare with another value
The right-hand value accepts either a literal or reference. For example:
- End date must be greater than or equal to Start date.
- Requested amount must be less than a limit from a Data Table or another answer.
- Confirmation value must equal a source field.
The picker filters for types accepted by the chosen operator. Use references instead of copying a changing limit into several rules.
Messages
Leave Error Message empty for the default operator message, or write a precise correction:
Enter a delivery date on or after the requested start date.
Good messages explain how to fix the answer. Avoid exposing internal field IDs, reference syntax, regex, or implementation details.
Repeatable fields
A repeatable parent is an array, so its available custom rules focus on length and empty/not empty. Use them to require exactly, at least, or at most a number of instances. Rules on child fields are evaluated at each concrete instance path.
Some type-specific controls are more direct—for example Multiple Choice minimum/maximum selections or File minimum/maximum files.
When validation runs
FormWork checks answers as they are saved and performs a fresh check before submission. After an attempted submit, relevant controls show their errors and completion is blocked until validation passes.
An answer can be persisted while still invalid; autosave and flush() are not the same as successful submission.
Visibility is considered during validation. Test cases where earlier answers show or hide a required field.
Pattern validation
Matches pattern accepts a regular expression for text. Keep patterns focused and provide a friendly custom message. Prefer built-in Is email, Is URL, Is number, and similar operators when they describe the requirement.
Publishing and testing
The builder only saves complete rule rows, and publish validation rejects invalid configuration. Before publishing:
- Test the boundary itself, one value below, and one above.
- Test empty values separately from malformed values.
- Test reference-based rules after changing the source.
- Test each repeated instance.
- Confirm the message still makes sense in context.
Every available condition is listed in Operators Reference.