Optional conditional keys
Using @optional
Here is an example of using the @optional annotation to conditionally include dictionary keys based on their values. The key is omitted when the value is empty or false.
The gdpr:
key will be removed when the region is not EU
.
-
start: set: record: name: Kina Halpue email: kina@cerb.example region: US return: output: name: {{record.name}} email: {{record.email}} gdpr@optional,bool: {{'EU' == record.region ? true}}
-
__return: output: name: Kina Halpue email: kina@cerb.example