---
title: Switch
slug: litmusedge/switch
docTags: 
createdAt: 2024-08-06T18:57:15.600Z
---

The Switch processor sends an incoming message to its output only when the message passes a rule you define.

## Why use Switch

Use this processor to filter or route messages based on a field's value, for example, only forwarding a message when a status field equals a specific value, or routing different values to different downstream processors using **Output**.

## How it works

Set **Field Name** to the field to check, **Check Value** to the value to compare it against, and **Check Value Type** to that value's expected data type. **Rule** determines how the comparison is made:

- `==` (Equals) and `!=` (Not Equals): the input value and check value must be equal, or different.
- `<` (Less than), `<=` (Less than or equals), `>` (Greater than), and `>=` (Greater than or equals): standard numeric or lexicographic comparison.
- **is true** and **is false**: only applicable to fields with a Bool data type.
- **is null**: passes only if the field isn't present in the input.
- **is not null**: passes only if the field is present in the input.
- **is of type**: compares the field's data type to **Check Value Type**.
- **contains**: only applicable to fields with a String or JSON data type.

For string comparisons, the processor uses Go's `strings.Compare` function, so strings are compared lexicographically (by character order) rather than by their numeric value.

Use **Output** to restrict where the result is published. Leave it empty to publish to every connected processor.

## Parameters

| **Parameter**     | **Details**                                                                                   |
| ----------------- | --------------------------------------------------------------------------------------------- |
| Rule              | The condition to check, for example, Equals or Not Equals.                                    |
| Field Name        | The field in the input message to check.                                                      |
| Check Value       | The value to compare **Field Name** against.                                                  |
| Check Value Type  | The expected data type of **Check Value**.                                                    |
| Output (Optional) | Restricts where the result is published. Leave empty to publish to every connected processor. |

## Related topics

- [Use the Switch Processor Function](docId:8v-BttpnSCRBkJENTe9CW)

