STARTS_WITH
STARTS_WITH:
arg: { arg } # required
search: { search } # required
Description
The STARTS_WITH
operation checks if a searchable value (arg
) starts with another value (search
). This operation is versatile and can be applied to both text and collection types.
- When
arg
is of typeText
orBytes
,STARTS_WITH
performs a prefix check to see if the string begins with thesearch
value. The comparison is case-insensitive forText
and case-sensitive forBytes
. - When
arg
is aList
or aSet
, the operation checks if first element of the collection issearch
value.
It returns a true
if the condition is met, and false
otherwise.
Parameters
arg
(Operation<Text
|Bytes
|List
|Set
>, required):- The value to be checked. This can be a single string (
Text
orBytes
) or a collection of strings (List
orSet
).
- The value to be checked. This can be a single string (
search
(Operation<Text
|Bytes
>, required):- The prefix value to search for at the beginning of the
arg
string or first element within thearg
collection.
- The prefix value to search for at the beginning of the
Return Type
Examples
-
Checking if a single Text field starts with a specific prefix:
This example checks if the
Name
field of a resource starts with "i-", which is common for AWS EC2 instance IDs. The check is case-insensitive.STARTS_WITH:
arg:
FIELD:
path: Name
search:
TEXT: "i-" -
Checking if first element in a List is
search
:Imagine a field
CA10__hostnames__c
contains a newline-separated list of hostnames. This example checks if first hostname is "web".STARTS_WITH:
arg:
LIST_FROM:
arg:
FIELD:
path: CA10__hostnames__c
separator: "\n"
search:
TEXT: "web" -
Using
NOT
to ensure a domain name does not start with a wildcard:This example checks if an ACM certificate's domain name does not start with a wildcard character
*
.NOT:
arg:
STARTS_WITH:
arg:
FIELD:
path: CA10__domainName__c
search:
TEXT: "*."
Relevant Unit Tests
For more detailed examples and to validate the behavior of the STARTS_WITH
operation, you can refer to the official unit tests: