CONTAINS
- CONTAINS(search_array, search_value)[source]
Checks whether a specified value exists within an array.
The CONTAINS function determines whether a given value or model component is present in the specified array. It returns a boolean result (True if the value is found, False otherwise). If either input is blank or in an error state, the formula evaluates to an error.
- Parameters:
search_array (
Operand) –The array to search through. Must be an array type and compatible with the type of search_value.
Supported types:
BOOLEAN_ARRAY
INTEGER_ARRAY
DECIMAL_ARRAY
STRING_ARRAY
DATE_ARRAY
DATETIME_ARRAY
TIME_ARRAY
OBJECT_ARRAY
search_value (
Operand|bool|str|float|int) –The value to search for within the array. Must be the singular type corresponding to the search_array element type (for example, INTEGER for INTEGER_ARRAY). Cannot itself be an array type. A ValueError is raised if the type does not match.
Supported types:
BOOLEAN
INTEGER
DECIMAL
STRING
DATE
DATETIME
TIME
OBJECT
- Return type:
- Returns:
A boolean value indicating whether the specified search_value is found in the search_array.
Supported types:
BOOLEAN
- Raises:
ValueError – If search_array is not an array type.
ValueError – If search_value is an array type.
ValueError – If the singular type of search_array does not match the type of search_value.
Examples
Basic usage:
CONTAINS([1, 2, 3], 2) # Returns True
Using a model component:
CONTAINS(my_array_field, my_value_field) # Returns True if my_value_field exists in my_array_field