Skip to content

Switch

Routes execution to one of several case ports.

@lainstack/flow/switch · Flow

Use this block to pick one path from up to 8 exact values. It compares the subject with each case value for equality and leaves on case_1 to case_8, or on default when no case matches. For ranges, ordering, contains tests or a plain yes or no, use @lainstack/flow/condition.

  • The cases are checked in order and the first match wins. The output is empty.
  • Case values must differ from each other, and each case must use its own port. Two equal values make the config invalid.
  • Every case value is resolved on each run, even after an earlier case matched. A case value that has no value, for example a reference to a block that did not run, fails the step with comparison_invalid. The subject fails the same way.
  • Text matching ignores letter case unless settings.matchCase is true. settings.timezone applies only to date and time values. Other value types take no settings.
  • Wire default if an unexpected value must not go unhandled.
Setting Key Type Details
Subject (required) subject Text
Cases (required) routes List At most 8 items.
Exit Port Notes
Case 1 case_1
Case 2 case_2
Case 3 case_3
Case 4 case_4
Case 5 case_5
Case 6 case_6
Case 7 case_7
Case 8 case_8
Otherwise default