validate.not-empty returns a given value if the value is not empty. If the the value is empty, an error is returned. Collections with no elements, including empty strings, are considered empty.

Function category: Validate


validate.not-empty(arg1, arg2)




Datum or a reference to a datum.


Error message to return if arg1 evaluates to null.


Let's say we were given the following data structure.

"first": 999,
"second": ""

Example 1: Determine if a value is empty

If we want to perform an operation but aren't sure whether the value will is empty or not empty, we can check if the value is empty using this function.

# Confirm if the first value is empty
validate.not-empty(driver_ids.first, "This error message won't be executed")
# Returns 999
# This indicates the value is not empty

Example 2: Determine if another value is empty

Using the same response and an error message, we can determine if another value is empty. If it is not empty, then the string is returned. If it is empty, then the error message is returned.

# Confirm if the second value is empty
validate.not-empty(driver_ids.second, "Value was empty!")
# Returns "Value was empty!"
# This indicates the second value is empty