Field validation
Last updated
Was this helpful?
Last updated
Was this helpful?
Field validation ensures that the data collected in your flows meets defined formatting, business, and quality requirements. Formsort supports both built-in and custom validators.
Formsort includes many default validators for common input types:
Number questions: Enforce min/max value, integer constraints, and step intervals.
Email fields: Automatically validate email formatting.
Text fields: Can be configured with length or character restrictions.
These default validators cover the most common cases. For advanced use cases, custom validators are available.
Custom validators allow you to define your own validation logic using regular expressions, custom code, or asynchronous API calls. They are defined at the workspace level and can be reused across flows.
Custom validators are composed of two main parts:
Metadata includes:
Name and description (used for identification in the Studio)
Answer type (e.g., string, number, object) – this controls which questions or variables can use the validator
Validators can contain multiple rules. Each rule must pass for the value to be considered valid.
Error: Blocking. The responder cannot proceed unless the input is corrected.
Warning: Non-blocking. The responder is alerted, but may choose to proceed.
Regular expressions (regex
) are available only for string inputs. You can create rules for inputs that must match or must not match a given pattern.
Example: Twitter Handle Validator
Must match
^[a-zA-Z0-9_]+$
A username can only contain alphanumeric characters (A–Z, 0–9) and underscores.
Must match
^.{1,15}$
Handles must be between 1 and 15 characters long.
Must not match
Admin` (case-insensitive)
For more flexibility, you can write custom validation functions using TypeScript.
Example:
Return a ValidatorResult
when the input is invalid.
Return undefined
when input passes validation.
Enable async mode to fetch data from external sources during validation using await
.
Example (hypothetical Twitter handle check):
Use the Test tab to try out inputs and preview validation behavior:
Regex rules: All rules are evaluated in parallel. Violations for each rule are shown independently.
Custom functions: Only the first failed check is returned.
Examples:
Once created, custom validators become selectable in Question settings (if the question’s data type matches the validator).
You can modify validators at any time. However:
Flows using the validator need to be redeployed to pick up changes.
Use the Show usages option to view which flows depend on a validator.
Custom validators can be deleted from the validator list.
Flows already using the validator will continue to function.
Deleted validators will no longer be available to assign to new questions or answers.
Using the Regular Experssion UI (described ) has the added benefit of evaluating all rules concurrently, and outputting an error message for each rule that is violated: