The case component is a more advanced branching component that allows you
to match against multiple match values (this is similar to a switch
statement in Javascript/Java/C/C++).
- value: (@ user.gender )
case:
male:
jump: male
female:
jump: female
default:
jump: other
Note, the values are matched literally, so in the case above the text
stored in (@ user.gender )
must exactly match either male
or female
to be a valid match.
If you would like to match against multiple patterns, then check out the
flow.match
component.
If you would like to match against multiple template evaluation criteria,
then check out the flow.cond
component.
Element details
type: meya.flow.component.case
class: CaseComponent
path: /meya/flow/component/case.py
signature: case
Fields
field | description | required | signature | default | type |
---|---|---|---|---|---|
spec | Override the original spec for this element. | ○ | ○ | null | Spec |
context | Send context data with this component's event. | ○ | ○ | {} | dict |
sensitive | Mark this component's event as sensitive. This will encrypt the event if the Sensitive Data integration has been enabled. | ○ | ○ | false | bool |
triggers | Activate these dynamic triggers when the component runs. Check the component triggers guide for more info. | ○ | ○ | [] | list |
value | Sets the value that needs to be matched against the multiple match values. If value is not defined, then the component will try use the value set in (@ flow.result ) , if no value could be found then an error is raised. | ○ | ○ | null | typing.Any |
ignorecase | Ignore the case of the value field. | ○ | ○ | null | bool |
case | Contains a set of match values and actions that will be matched against the value defined in the value field. The action is a component reference that is called when value matches the match value. | ◉ | ◉ | dict | |
default | This is the default action should (@ flow.result ) not match any of the match values. | ◉ | ○ | ActionComponentSpec | |
Usage reference
Basic
triggers:
- keyword: meya.flow.component.case
steps:
- case:
ANY: COMPONENT
default: COMPONENT
Full
triggers:
- keyword: meya.flow.component.case
steps:
- spec:
type: STRING
data:
STRING: ANY
timeout: 123
trigger_when: ANY
context:
STRING: ANY
sensitive: false
triggers:
- type: STRING
data:
STRING: ANY
timeout: 123
trigger_when: ANY
value: ANY
ignorecase: false
case:
ANY: COMPONENT
default: COMPONENT