Skip to content

Adding a `contains` function to be used in expressions

Current situation

Expressions cannot be used to check if a list or dictionary contains a given item. We do have a ~= operator that allows for regex matches, but there is no way to check if, say, a variable is defined.

Desired outcome

A way to check if an item is contained in a collection, and a way to produce collections, too.

contains

contains( search, item )

Returns true if search contains item. If search is an array or object, this function returns true if the item is an element in the array or a key of the object. If search is a string, this function returns true if the item is a substring of search. This function is not case sensitive. Casts values to a string.

toJSON

toJSON(value)

Returns a pretty-print JSON representation of value. You can use this function to debug the information provided in contexts.

fromJSON

fromJSON(value)

Returns a JSON object or JSON data type for value. You can use this function to provide a JSON object as an evaluated expression or to convert environment variables from a string.

startsWith

startsWith( searchString, searchValue )

Returns true when searchString starts with searchValue. This function is not case-sensitive. Casts values to a string.

endsWith

endsWith( searchString, searchValue )

Returns true if searchString ends with searchValue. This function is not case-sensitive. Casts values to a string.

Edited by Martin Lafaix