Universal Condition Gate (YC)
A pass-through gate for ANY data type, opened by a text condition — including a not-switch
- input
- output
- is_matched
The most flexible of the pack's three condition switches - and the one the other two are built from. Compare two strings; if the comparison passes, whatever arbitrary value you plugged into input flows through to output. If it fails, you get None. The universal type means it doesn't care whether you're gating a conditioning, an image, a model, or a pile of masks, and the invert toggle flips the test into a "block when it matches" gate.
What it's actually for
Conditional plumbing. Sometimes you don't want to route between two values - you want to allow or suppress one value based on a condition. This node is the valve: text matches, the value passes; text doesn't match, the port is dry. It's the natural fit for loop and batch workflows where some iterations should feed a branch and others should not, and because it takes any type it slots into graphs that the mask- and image-specific switches can't touch. It can even be used as a pure text comparator by ignoring input and reading is_matched.
How it works
String comparison core, same as its siblings: input_text vs preset_text, with case_sensitive controlling exactness. Then the gate logic:
- invert = off → pass the input when matched
- invert = on → pass the input when not matched
is_matched always reports the raw comparison result, regardless of invert, so you get both the boolean and the gated value. On modern ComfyUI it uses lazy evaluation, so the node's input branch only runs when the gate actually needs it - upstream heavy nodes don't execute when the gate closes. When the gate blocks, output is None, which downstream wildcard-typed ports accept - so the graph doesn't crash, it just gets nothing.
Inputs and outputs
- input_text - the text under test
- preset_text - what it's compared against
- case_sensitive - default on
- invert - flip the pass condition
- input - the arbitrary value to gate (any type)
Outputs: output (the value, or None when blocked) and is_matched (the boolean).
Install
In ComfyUI-YCNodes. ComfyUI Manager → search "ComfyUI-YCNodes" → install, restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/yichengup/ComfyUI-YCNodes
Standard deps (torch, numpy, pillow, opencv-python, scipy), no models.
Where people get burned
Nonedoesn't mean "skip." A blocked gate passesNoneto whatever's downstream, and aNoneconditioning or model will break the next node. If the consumer isn't None-aware, guard after the gate rather than before.- Exact match only. Same
==comparison as the siblings - whitespace and case (unless you flipcase_sensitive) matter. Trailing newline = silently no match. - Forgetting invert. A gate that appears to pass everything (or nothing) is usually the invert toggle being on without you remembering it. It's a genuine feature - "block when this matches" is useful - but it reads as a bug when you forget it's there.
The pack's mask and text switches are this node specialized; the Universal Gate is the general one. When your condition-driven graph needs to gate something that isn't an image or a mask, this is the valve to use.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| input_text | STRING | 输入文本,将与预设文本比较 | |
| preset_text | STRING | 预设文本,用于与输入文本比较 | |
| case_sensitive | BOOLEAN | true | 是否区分大小写 |
| invert | BOOLEAN | false | 反转逻辑:选择True时,不匹配则通过;选择False时,匹配则通过 |
| inputopt | * | 任意类型的输入,当条件匹配时将被传递到输出 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| output | * | — |
| is_matched | BOOLEAN | — |