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
argis of typeTextorBytes,STARTS_WITHperforms a prefix check to see if the string begins with thesearchvalue. The comparison is case-insensitive forTextand case-sensitive forBytes. - When
argis aListor aSet, the operation checks if first element of the collection issearchvalue.
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 (
TextorBytes) or a collection of strings (ListorSet).
- 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
argstring or first element within theargcollection.
- 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
Namefield 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__ccontains 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
NOTto 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: