Skip to main content

ASSERT

Use the ASSERT function to generate a specific error message when a condition has not been met.

info

This function is only available in Validation Formulas. It is used to display meaningful errors messages to users when filling in forms.

Use

ASSERT( condition, message )
Generate a specific validation error message if the logical condition evaluates to FALSE.

ParameterRequiredDescription
conditionYesthe condition to test, which must result in either TRUE or FALSE
messageYesthe error message to display if the condition is FALSE

Returns'Logical'

Example

Validating a Numerical Range

This example ensures that a user enters a number within a specific range, such as a quantity or score, and provides clear feedback if the value falls outside that range.

  • Formula: ASSERT(AND(this >= 1, this <= 10), "The number must be between 1 and 10.")
  • Logic:
    • this: Refers directly to the value the user is currently entering in the field.
    • AND(...): This logical test checks if the value is both greater than or equal to 1 and less than or equal to 10.
    • Result: If the user enters a "15", the AND condition evaluates to FALSE, and GoApprove will display the specific message: "The number must be between 1 and 10.".

Multiple Specific Text Requirements

You can use multiple ASSERT functions in a single validation to provide different messages based on which specific requirement the user failed to meet.

  • Scenario: A text input must start with the word "hello" and end with the word "goodbye".
  • Formula:
    AND(
    ASSERT(BEGINS(this, "hello"), "Value must start with 'hello'"),
    ASSERT(ENDS(this, "goodbye"), "Value must end with 'goodbye'")
    )
  • Logic:
    • The first ASSERT uses the BEGINS function to check the start of the text.
    • The second ASSERT uses the ENDS function to check the end of the text.
    • Result: If a user enters "hello-world", the first condition is TRUE, but the second is FALSE. Instead of a generic error, the form will specifically tell the user the value "must end with 'goodbye'.".