> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bringits.com/llms.txt
> Use this file to discover all available pages before exploring further.

# If-Else

> Conditional execution of commands based on logical evaluations

The If-Else command (Command Type: 1100) executes different sets of commands depending on whether a logical condition evaluates to `true` or `false`.

## Command Type

**Command Type ID:** 1100

## Parameters

| Parameter         | Type                                | Description                                                                   | Required |
| ----------------- | ----------------------------------- | ----------------------------------------------------------------------------- | -------- |
| **condition**     | SimpleCondition or ComplexCondition | The logical condition to evaluate                                             | Yes      |
| **trueCommands**  | Array of Command                    | Commands to execute if the condition evaluates to `true`                      | Yes      |
| **timeout**       | number                              | Timeout for the command in milliseconds                                       | Yes      |
| **context**       | string                              | Execution context for evaluating the condition. Defaults to `"CommandResult"` | No       |
| **falseCommands** | Array of Command                    | Commands to execute if the condition evaluates to `false`                     | No       |

### SimpleCondition

| Field         | Type      | Description          | Required |
| ------------- | --------- | -------------------- | -------- |
| **left**      | Operand   | Left-side operand    | Yes      |
| **operation** | Operation | Comparison operation | Yes      |
| **right**     | Operand   | Right-side operand   | Yes      |

### Operand Types

**PropertyOperand** — references a named property:

| Field   | Type         | Description   |
| ------- | ------------ | ------------- |
| `type`  | `"property"` | Fixed literal |
| `value` | string       | Property name |

**ValueOperand** — a literal value:

| Field   | Type                              | Description       |
| ------- | --------------------------------- | ----------------- |
| `type`  | `"value"`                         | Fixed literal     |
| `value` | string / number / boolean / array | The literal value |

### Operation Values

| Category | Possible Values                                                              |
| -------- | ---------------------------------------------------------------------------- |
| String   | `"includes"`, `"startsWith"`, `"endsWith"`, `"=="`, `"!="`, `"==="`, `"!=="` |
| Number   | `">"`, `">="`, `"<"`, `"<="`, `"=="`, `"!="`, `"==="`, `"!=="`               |
| Array    | `"includes"`, `"=="`, `"!="`, `"==="`, `"!=="`                               |

### ComplexCondition

Combines multiple simple or complex conditions:

| Field          | Type                                         | Description       | Required |
| -------------- | -------------------------------------------- | ----------------- | -------- |
| **conditions** | Array of SimpleCondition or ComplexCondition | Nested conditions | Yes      |
| **operator**   | string                                       | `"AND"` or `"OR"` | Yes      |

## Usage Examples

### Simple String Check

```json theme={null}
{
  "command": "if-else",
  "params": {
    "condition": {
      "left": { "type": "property", "value": "status" },
      "operation": "==",
      "right": { "type": "value", "value": "active" }
    },
    "trueCommands": [
      { "id": 1, "type": "PARSE", "params": { ... } }
    ],
    "falseCommands": [],
    "timeout": 5000
  }
}
```

### Complex AND Condition

```json theme={null}
{
  "command": "if-else",
  "params": {
    "condition": {
      "operator": "AND",
      "conditions": [
        {
          "left": { "type": "property", "value": "count" },
          "operation": ">",
          "right": { "type": "value", "value": 0 }
        },
        {
          "left": { "type": "property", "value": "status" },
          "operation": "==",
          "right": { "type": "value", "value": "live" }
        }
      ]
    },
    "trueCommands": [],
    "timeout": 5000
  }
}
```

## Common Use Cases

* **Guard Clauses**: Skip processing if data is empty or invalid
* **Branching Logic**: Take different parse paths based on a field value
* **Conditional Sinking**: Only publish to a sink when data meets a criteria

## Related Commands

* [Command Validation](/stream/commands/validation/command-validation) - Validate data before branching
* [Filter](/stream/commands/parse/filter) - Filter arrays by field values
