
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
-
Open Automation Builder: Go to Manage > Automations >
<Automation Name>
> View > Edit
Select the Start step and then click the Variable data section to expand it. -
Click the Variable you want add a validation formula to. This will open the Edit variable dialog.
Click the Validation tab to show the Formula Builder.
Creating output validation formulas
-
Open Automation Builder: Go to Manage > Automations >
<Automation Name>
> View > Edit
Select the Trigger or Activity step and then click the Output data section to expand it. -
Click the Output you want add a validation formula to. This will open the Edit output dialog.
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
Minimum length
Maximum length
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
Restricting dates
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 specific days
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
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
Must contain at least one non-empty item
Must contain between one and five non-empty items
No item can be blank
Each number must be between 1 and 10
Each item must either start with "abc" or “xyz”
Each item must start with "abc" followed by 4 numbers
Each date must in the past
TODO.
COUNTALL(this) = COUNTIF(this, "<" & TEXT(TODAY(), "yyyy-MM-dd"))
See function(s): COUNTALL, COUNTMATCH