Enumerations
Enumerations define a named set of accepted string values for use in action parameters.
Table of contents
Syntax
enum typeName {
'Option1',
'Option2'
}
Each value is raw text (single quoted string). A trailing comma after the last value is allowed.
Using enums in action definitions
Enums are used as parameter types in action definitions. When an action parameter has an enum type, only the declared values are accepted.
enum hashType {
'MD5',
'SHA1',
'SHA256',
'SHA512',
}
action 'is.workflow.actions.hash' hash(variable input, hashAlgorithm ?algorithm = "MD5")
Calling the action with an enum value:
#include 'actions/crypto'
@input = "Hello, Cherri!"
const result = hash(@input, "SHA256")
Standard library enums
The standard library action pages show the enum definition inline alongside each action that uses one. These enums are defined inside the Cherri compiler - you do not need to define them yourself when using standard library actions.
For example, from the Crypto actions:
enum hashType {
'MD5',
'SHA1',
'SHA256',
'SHA512',
}
hash(variable input, hashAlgorithm ?algorithm = "MD5")
When calling hash(), pass one of the declared string values as the argument.