Skip to main content

Overview

Validations determine whether an automation should execute. They act as gatekeepers - if a validation fails, the automation’s actions are skipped entirely. This helps you create conditional logic without complex action blocks.

Pre-Execution Check

Validate before any actions run

Multiple Types

Expression, REST API, or Location checks

Short-Circuit

Skip all actions if validation fails

Custom Messages

Show user-friendly error messages

How Validations Work

Automation Triggered

  ┌───────────────┐
  │  Validation   │
  └───────┬───────┘

    ┌─────┴─────┐
    │  Passes?  │
    └─────┬─────┘
       /     \
     Yes      No
      ↓        ↓
  Execute   Skip All
  Actions   Actions
             + Show
             Error
Validations run before any action blocks. If the validation returns false, all action blocks are skipped and an optional error message is shown to the user.

Validation Types

1. Expression Validation

Write JavaScript expressions that return true or false. Use for:
  • Checking data field values
  • Comparing dates or numbers
  • Complex conditional logic
Example: Require minimum order amount
// Validation passes if order is $50 or more
task.data.order_amount >= 50
Example: Validate date is in future
// Validation passes if delivery date is after today
new Date(task.data.delivery_date) > new Date()
Example: Check user role
// Only allow managers to proceed
loggedInUser.role === "Manager"

2. REST API Validation

Call an external API to validate. The automation proceeds only if the API returns a successful response matching your criteria. Use for:
  • Verifying data with external systems
  • Credit checks or inventory availability
  • Third-party validation services
Configuration:
FieldDescription
URLAPI endpoint to call
MethodHTTP method (GET, POST, etc.)
HeadersRequest headers (auth, content-type)
BodyRequest payload with data field placeholders
Success ConditionExpression to evaluate the response
Example: Check inventory before order
// API Configuration
{
  "url": "https://api.inventory.com/check",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer {{secrets.INVENTORY_API_KEY}}",
    "Content-Type": "application/json"
  },
  "body": {
    "product_id": "{{task.data.product_id}}",
    "quantity": "{{task.data.quantity}}"
  }
}

// Success Condition
response.data.available === true
Example: Verify customer credit
// API Configuration
{
  "url": "https://api.credit.com/verify/{{task.data.customer_id}}",
  "method": "GET"
}

// Success Condition
response.data.credit_limit >= task.data.order_total

3. Location Validation

Verify the user is at or near a specific location before allowing the automation to proceed. Use for:
  • Ensuring field workers are on-site
  • Geo-fenced task completion
  • Delivery verification
Configuration:
FieldDescription
Target LocationData field containing the expected location
User LocationCurrent user’s GPS coordinates
RadiusMaximum allowed distance (meters)
Example: Verify user is at delivery location
Target: task.data.delivery_address
User: loggedInUser.location
Radius: 100 meters

Adding a Validation

1

Open Automation

Navigate to the automation you want to add validation to
2

Click Add Validation

In the automation editor, click Add Validation
3

Select Type

Choose Expression, REST API, or Location
4

Configure

Enter your validation logic based on the type
5

Set Error Message

Enter the message to show users when validation fails
6

Save

Save the automation

Error Messages

When validation fails, you can display a custom error message to the user:
// Validation
task.data.quantity <= task.data.stock_available

// Error Message
"Insufficient stock. Only {{task.data.stock_available}} items available."
Error messages support data field placeholders using {{field}} syntax.

Best Practices

Complex logic is better handled in action block conditions. Validations should be clear pass/fail checks.
Help users understand why the validation failed and what they can do about it.
REST API validations add network latency. Use expression validations for local checks.
Decide whether API errors should fail validation (safe default) or pass through.

Validation vs Conditions

AspectValidationCondition
ScopeEntire automationSingle action block
On FailureSkip all actionsSkip that block only
Error MessageCan show to userSilent skip
Use CasePre-flight checksBranching logic
Use validations when you want to prevent the entire automation from running. Use conditions when you want to selectively run different action blocks.

Common Validation Patterns

// Ensure required data is present
task.data.customer_name && task.data.customer_phone
// Only allow during 9 AM - 6 PM
const hour = new Date().getHours();
hour >= 9 && hour < 18
// Only supervisors or managers
['Supervisor', 'Manager'].includes(loggedInUser.role)
// Validate email format
/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(task.data.email)

For AI Agents

Validation Structure

interface AutomationValidation {
  type: 'expression' | 'rest_api' | 'location';
  config: ExpressionConfig | RestApiConfig | LocationConfig;
  errorMessage?: string;
}

interface ExpressionConfig {
  expression: string;  // JavaScript expression returning boolean
}

interface RestApiConfig {
  url: string;
  method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
  headers?: Record<string, string>;
  body?: any;
  successCondition: string;  // JavaScript expression
}

interface LocationConfig {
  targetLocation: string;  // Data field path
  userLocation: string;    // Usually "loggedInUser.location"
  radiusMeters: number;
}

Available Variables

VariableDescription
taskCurrent task object with all data fields
task.dataUser-defined data field values
loggedInUserCurrent user information
loggedInUser.roleUser’s role
loggedInUser.teamUser’s team
loggedInUser.locationUser’s current GPS location
responseREST API response (for API validations)
secretsStored secret values

UI Components

ComponentLocationPurpose
ValidationEditor/src/views/automations/ValidationEditor/Validation configuration
ExpressionEditor/src/components/LowCode/JavaScript editor
ApiConfigEditor/src/views/automations/ApiConfig/REST API setup
LocationPicker/src/components/LocationPicker/Location selection

Event Tracking

// Validation events
AutomationEvents.VALIDATION_STARTED
AutomationEvents.VALIDATION_PASSED
AutomationEvents.VALIDATION_FAILED
AutomationEvents.VALIDATION_ERROR