Skip to main content
Learning
Controlling when outputs and variables are valid

Validation Logic uses formulas to check if a specific Output or Variable is correct. The formula will give either TRUE or FALSE. If it returns TRUE, the field is valid; if it returns FALSE, the field is invalid.

Here's how to create validation formulas:

Creating variable validation formulas

  1. Open Automation Builder: Go to Manage > Automations > <Automation Name> > View > Edit

    image
    Select the Start step and then click the Variable data section to expand it.

  2. Click the Variable you want add a validation formula to. This will open the Edit variable dialog.

    image
    Click the Validation tab to show the Formula Builder.

Creating output validation formulas

  1. Open Automation Builder: Go to Manage > Automations > <Automation Name> > View > Edit

    image
    Select the Trigger or Activity step and then click the Output data section to expand it.

  2. Click the Output you want add a validation formula to. This will open the Edit output dialog.

    image
    Click the Validation tab to show the Formula Builder.

Writing validation formulas

Click inside the Formula Builder to start writing your formula.

Validation formulas return either TRUE or FALSE. If the formula returns TRUE, the Output or Variable is valid; if it returns FALSE, it is invalid.

If you don't include a validation formula for a Variable or Output, it is assumed to always be valid.

When writing validation formulas, use the keyword this to refer to the Output or Variable you're validating. For instance, if you're validating a variable called ClaimValue, use this instead of $ClaimValue in your formula. For example, to ensure that ClaimValue is always greater than zero, write this > 0.

You can also include other data in your validation formulas. For example, to ensure that two text outputs, @Trigger.out.Text1 and @Trigger.out.Text2, are identical, you would write a validation formula for @Trigger.out.Text2 as EXACT(this, @Trigger.out.Text1).

When validating Outputs that are used to capture information on forms, it's helpful to tell users exactly what's wrong with their entries instead of just saying the value is invalid. You can do this with the ASSERT function. For example, if a number should be between 1 and 10, you can use ASSERT to explain when the number doesn't meet these conditions. Here's how:

AND
(
ASSERT(this >= 1, "must be greater than zero"),
ASSERT(this <= 10, "cannot be greater than ten"),
)

Take a look at some validation formula examples below.

To learn more about the Formula Builder, click here.

Examples

Using ASSERT in validation formulas

In this example, ASSERT is combined with the AND function to display an error message if the AND function returns FALSE.

ASSERT(
AND(
BEGINS(this, "hello"),
ENDS(this, "goodbye")
),
"Value needs to begin with 'hello' and end with 'goodbye'"
)

If the user enters a value that starts with "hello" but doesn't end with "goodbye," the same error message will appear, even if the beginning part is correct. This might be what you want, but if you need more specific feedback, you can adjust the ASSERT placement like this:

AND(
ASSERT(BEGINS(this, "hello"), "must begin with 'hello'"),
ASSERT(ENDS(this, "goodbye"), "must end with 'goodbye'")
)

Now, if the user enters a value that starts with "hello" but doesn't end with "goodbye," the error message will change to "must end with 'goodbye'."

Single value validation formulas

Here are some examples of single value validation formulas. You can mix and match these examples to create a formula that fits your specific needs.

Cannot be empty

Cannot be blank.

NOTBLANK(this)

See function(s): NOTBLANK

Minimum length

TODO.

LEN(this) > 5

See function(s): LEN

Maximum length

TODO.

LEN(this) <= 20

See function(s): LEN

Character restrictions

Must contain the @ character, an uppercase character and a lowercase character.

AND
(
REGEX_MATCH(this, "@{1,}"),
REGEX_MATCH(this, "[a-z]{1,}"),
REGEX_MATCH(this, "[A-Z]{1,}")
)

Must contain at least two @ characters.

REGEX_MATCH(this, "^(.*@.*){2,}$"),

Must only contain numbers.

REGEX_MATCH(this, "^[0-9]{1,}$"),

Must only contain lowercase letters.

REGEX_MATCH(this, "^[a-z]{1,}$"),

Must only contain uppercase letters.

REGEX_MATCH(this, "^[A-Z]{1,}$"),

Cannot contain the @ character.

NOT(REGEX_MATCH(this, "@{1,}"))

Cannot contain spaces.

NOT(REGEX_MATCH(this, "[ ]{1,}"))

Cannot contain leading space(s).

NOT(REGEX_MATCH(this, "^[ ]{1,}"))

Cannot contain trailing space(s).

NOT(REGEX_MATCH(this, "[ ]{1,}$"))

See function(s): NOT, REGEX_MATCH

Specific patterns of characters

Must be a valid email address.

REGEX_MATCH(this, "^((([!#$%&'*+\\-/=?^_`{|}~\\w])|([!#$%&'*+\\-/=?^_`{|}~\\w][!#$%&'*+\\-/=?^_`{|}~\\.\\w]{0,}[!#$%&'*+\\-/=?^_`{|}~\\w]))[@]\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*)$")

Must be a telephone number either in UK natiobal format or in E.164 format. No spaces are permitted.

OR
(
REGEX_MATCH(this, "^0[^0][0-9]{9}$"),
REGEX_MATCH(this, "^[+]44[^0][0-9]{9}$")
)

Must be a valid account number starting 'ADT' followed by 7 numbers.

REGEX_MATCH(this, "^ADT[0-9]{7}$")

See function(s): NOT, OR, REGEX_MATCH

Number ranges

Allow only positive value.

this > 0

Limit to a maximum value (e.g. 100).

this <= 100

Limit to a range of values (e.g. between 42 and 50).

AND
(
this >= 42,
this >= 50
)

Disallow decimal numbers.

DECIMALS(this) = 0

Require exactly 2 decimal places.

DECIMALS(this) = 2

See function(s): AND, DECIMALS

Restricting dates

Only past dates are allowed.

this < TODAY()

Only today or future dates are allowed.

this >= TODAY()

Ensure from the date of birth that the person is at least 18 years old.

DAYS(TODAY(), this) / 365 >= 18

See function(s): DAYS, TODAY

Only weekdays

Only allow weekdays by excluding Saturday (7) and Sunday (1).

AND
(
WEEKDAY(this) <> 1,
WEEKDAY(this) <> 7
)

Only allow weekdays by including Monday (2) to Friday (6).

AND
(
WEEKDAY(this) >= 2,
WEEKDAY(this) <= 6,
)

See function(s): WEEKDAY

Only weekends

Only allow weekends by including only Saturday (7) and Sunday (1).

OR
(
WEEKDAY(this) = 1,
WEEKDAY(this) = 7
)

See function(s): OR, WEEKDAY

Only specific days

Only allow Tuesday (3).

WEEKDAY(this) = 3

See function(s): WEEKDAY

Exclude dates

Only allow dates that are not in a list, e.g public holidays.

MATCH(
this,
{
DATE(2024, 1, 1),
DATE(2024, 3,29),
DATE(2024, 4, 1),
DATE(2024, 5, 6),
DATE(2024, 5,27),
DATE(2024, 8,26),
DATE(2024,12,25),
DATE(2024,12,26),
DATE(2025, 1, 1),
DATE(2025, 4,18),
DATE(2025, 4,21),
DATE(2025, 5, 5),
DATE(2025, 5,26),
DATE(2025, 8,25),
DATE(2025,12,25),
DATE(2025,12,26)
}
) = 0

See function(s): DATE, MATCH

Multi-value validation formulas

Here are some examples of validation formulas for arrays of values. You can combine these examples to create a formula that suits your needs.

Must contain at least one item

TODO.

COUNTALL(this) > 0

See function(s): COUNTALL

Must contain at least one non-empty item

TODO.

COUNTA(this) > 0

See function(s): COUNTA

Must contain between one and five non-empty items

TODO.

AND
(
COUNTA(this) > 0,
COUNTA(this) <= 5
)

See function(s): AND, COUNTA

No item can be blank

TODO.

COUNTBLANK(this) = 0

See function(s): COUNTBLANK

Each number must be between 1 and 10

TODO.

AND
(
COUNTALL(this) = COUNTIF(this, ">=1"),
COUNTALL(this) = COUNTIF(this, "<=10")
)

See function(s): AND, COUNTALL, COUNTIF

Each item must either start with "abc" or “xyz”

TODO.

OR
(
COUNTALL(this) = COUNTIF(this, "abc*"),
COUNTALL(this) = COUNTIF(this, "xyz*")
)

See function(s): COUNTALL, COUNTIF, OR

Each item must start with "abc" followed by 4 numbers

TODO.

COUNTALL(this) = COUNTMATCH(this, "^abc[0-9]{4}$", FALSE)

See function(s): COUNTALL, COUNTMATCH

Each date must in the past

TODO.

COUNTALL(this) = COUNTIF(this, "<" & TEXT(TODAY(), "yyyy-MM-dd"))

See function(s): COUNTALL, COUNTMATCH

Each logical must be TRUE

TODO.

COUNTALL(this) = COUNTIF(this, TRUE)

See function(s): COUNTALL, COUNTMATCH