Switch Node
Route messages based on their property values or sequence position.
Details
When a message arrives, the node will evaluate each of the defined rules and forward the message to the corresponding outputs of any matching rules.
Optionally, the node can be set to stop evaluating rules once it finds one that matches.
The rules can be evaluated against an individual message property, a flow or global context property, environment variable or the result of a JSONata expression.
Rules
There are four types of rule:
- Value rules are evaluated against the configured property
- Sequence rules can be used on message sequences, such as those generated by the Split node
- A JSONata Expression can be provided that will be evaluated against the whole message and will match if the expression returns a true value.
- An Otherwise rule can be used to match if none of the preceding rules have matched.
Notes
The is true/false
and is null
rules perform strict comparisons against those types.
They do not convert between types.
The is empty
and is not empty
rules can be used to test the length of Strings, Arrays and Buffers, or the number of properties an Object has.
Neither rule will pass if the property being tested has a boolean, null or undefined value.
Note: Check out the
match node
to match messages based on property values.