Skip to Content
Form EditorValidation Flows

Validation Flows

Validation flows allow you to create custom validation logic for your form questions. Instead of relying on basic validation rules like min/max length or regex patterns, you can build complex validation logic using the visual flow editor.

How Validation Flows Work

When a validation flow is attached to a question, it runs in two scenarios:

  1. Real-time validation - When the user finishes typing and moves away from the field (on blur)
  2. Form submission - When the user submits the entire form

The validation flow receives the current value of the question and must return either:

  • { success: true } - The value is valid
  • { success: false, error: "Error message" } - The value is invalid with a custom error message

Setting Up a Validation Flow

1. Create a Validation Flow

First, create a new flow in the Flow Editor:

  1. Go to the Flows section in your dashboard
  2. Click Create Flow
  3. Give it a descriptive name like “Email Domain Validation”
  4. Set up your validation logic using the visual flow editor

2. Configure the Flow Input

Your validation flow should have a Start node that defines the inputs it expects:

Primary Input: value

  • Input Name: value (this will receive the question’s current value)
  • Type: Match the type of your question (string, number, boolean, etc.)
  • Required: Yes

Secondary Input: answers (optional)

  • Input Name: answers (this will receive all form answers)
  • Type: object (contains all form answers as key-value pairs)
  • Required: No (but useful for cross-field validation)

The answers parameter allows you to validate based on other questions’ values, enabling complex cross-field validation scenarios.

3. Build Your Validation Logic

Add nodes to your flow to perform validation checks. Common validation patterns include:

Email Domain Validation

  • Use a Condition node to check if the email contains specific domains
  • Use String Operations to extract and validate the domain part
  • Return success/error based on your criteria

Phone Number Format Validation

  • Use Regex operations to validate phone number patterns
  • Check for specific country codes or formats
  • Return appropriate error messages

Custom Business Logic

  • Use HTTP Request nodes to validate against external APIs
  • Check against databases or external services
  • Implement complex business rules

4. Configure the Flow Output

Your flow must return the correct response format. Use an End node with:

  • Output Name: success (boolean)
  • Output Name: error (string, optional)

Attaching to a Question

1. Open Question Settings

  1. In your form editor, click on any question
  2. Go to the Advanced section in the question settings panel

2. Select Validation Flow

  1. In the Validation Flow section, click Select Validation Flow
  2. Browse your available flows and select the appropriate one
  3. The flow will now be attached to that question

3. Test Your Validation

  1. Preview your form
  2. Enter invalid data in the question
  3. Move away from the field or submit the form
  4. You should see your custom error message

Example Validation Flows

Email Domain Validation

This flow validates that email addresses are from allowed domains:

// Start node receives: { value: "user@example.com" } // Condition: Check if email contains allowed domains const allowedDomains = ["company.com", "partner.org"]; const domain = value.split("@")[1]; if (allowedDomains.includes(domain)) { return { success: true }; } else { return { success: false, error: "Please use a company email address" }; }

Phone Number Validation

This flow validates phone numbers for a specific format:

// Start node receives: { value: "+1-555-123-4567" } // Regex pattern for US phone numbers const phoneRegex = /^\+1-\d{3}-\d{3}-\d{4}$/; if (phoneRegex.test(value)) { return { success: true }; } else { return { success: false, error: "Please enter a valid US phone number in format: +1-XXX-XXX-XXXX" }; }

Age Verification

This flow validates that users are over 18:

// Start node receives: { value: "25" } const age = parseInt(value); const currentYear = new Date().getFullYear(); const birthYear = currentYear - age; if (age >= 18) { return { success: true }; } else { return { success: false, error: "You must be at least 18 years old to proceed" }; }

Best Practices

1. Clear Error Messages

Provide specific, helpful error messages that guide users to correct input:

// Good return { error: "Please enter a valid company email address" }; // Bad return { error: "Invalid email" };

2. Performance Considerations

  • Keep validation flows lightweight for real-time validation
  • Use caching for external API calls when possible
  • Avoid complex computations that might slow down the user experience

3. Testing

  • Test your validation flows thoroughly with various inputs
  • Include edge cases like empty values, special characters, etc.
  • Test both the real-time validation and form submission scenarios

4. Error Handling

Always handle potential errors gracefully:

try { // Your validation logic return { success: true }; } catch (error) { return { success: false, error: "Validation failed. Please try again." }; }

Advanced Features

Access to Form Context

Your validation flow can access the current form answers through the answers parameter:

// You can access other form fields const email = answers.email; const name = answers.fullName; // Use this for cross-field validation if (email.includes(name.split(" ")[0].toLowerCase())) { return { success: true }; } else { return { success: false, error: "Email should contain your first name" }; }

External API Validation

You can validate against external services:

// Make HTTP request to validate const response = await fetch("https://api.example.com/validate", { method: "POST", body: JSON.stringify({ value }), headers: { "Content-Type": "application/json" } }); const result = await response.json(); if (result.valid) { return { success: true }; } else { return { success: false, error: result.message }; }

Troubleshooting

Common Issues

  1. Flow not running: Check that the flow is properly attached to the question
  2. Incorrect response format: Ensure your flow returns { success: boolean, error?: string }
  3. Performance issues: Optimize your flow logic for faster execution
  4. External API failures: Add proper error handling for network requests

Debugging Tips

  1. Use Log nodes in your flow to debug the validation process
  2. Check the flow execution logs in the Flow Editor
  3. Test your flow independently before attaching to a question
  4. Verify input/output types match your question’s data type

Validation flows provide powerful, flexible validation capabilities that go far beyond basic form validation rules. With proper setup and testing, they can handle complex business logic and provide excellent user experience.

Last updated on