# \`SWITCH\` node question about options

**URL:** <https://discourse.nodered.org/t/switch-node-question-about-options/76086>\
**Category:** General\
**Created:** [3 March 2023 22:56 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086 "2023-03-03T22:56:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 March 2023 22:56 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/1 "2023-03-03T22:56:48Z")

</div>

# This is about the `SWITCH` node and it's options.

Ok, second attempt and I hope this effort is better than my other question I asked poorly.

Say I have a message that is an object.

eg:

```auto
msg = {"payload":"this is the payload","important_piece":"this needs to be parsed"};

```

I hope that is correct for structure as I am _flying on fumes_ just now.

I need to allows the message to pass ONLY if the `important_piece` is set/there/valid.

There are times when it is just `msg.payload` and nothing else. So I do NOT want this message to go through.

So that is where the `switch` node comes into play.

But what do I put in it?

`is not null`  
or  
`is not empty`

Sorry, it is an elephant.  
But I am having trouble getting my head around it because of my other post and the solution used there to get things to work.

Example flow:

```auto
[{"id":"bf7938a4d1c0b9fc","type":"change","z":"0918ee609bf69fc7","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"This is the payload","tot":"str"},{"t":"set","p":"important_piece","pt":"msg","to":"This needs to be parsed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1900,"y":510,"wires":[["239df70d331c7a67","6051957128a32947"]]},{"id":"43b0a867366e9201","type":"inject","z":"0918ee609bf69fc7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1740,"y":510,"wires":[["bf7938a4d1c0b9fc"]]},{"id":"239df70d331c7a67","type":"switch","z":"0918ee609bf69fc7","name":"","property":"important_piece","propertyType":"msg","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":2100,"y":530,"wires":[["716870566126c0ad"]]},{"id":"6051957128a32947","type":"switch","z":"0918ee609bf69fc7","name":"","property":"important_piece","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":2100,"y":490,"wires":[["eaf6e8ee778738c7"]]},{"id":"f7d96b70408812c1","type":"change","z":"0918ee609bf69fc7","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"This is the payload","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1900,"y":550,"wires":[["239df70d331c7a67","6051957128a32947"]]},{"id":"716870566126c0ad","type":"debug","z":"0918ee609bf69fc7","name":"debug 65","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2320,"y":530,"wires":[]},{"id":"eaf6e8ee778738c7","type":"debug","z":"0918ee609bf69fc7","name":"debug 66","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2320,"y":490,"wires":[]},{"id":"24ea464f7f379813","type":"inject","z":"0918ee609bf69fc7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1740,"y":550,"wires":[["f7d96b70408812c1"]]}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [3 March 2023 23:34 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/2 "2023-03-03T23:34:30Z")

</div>

try using`is null`

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 March 2023 23:39 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/3 "2023-03-03T23:39:55Z")

</div>

`is null` would pass it if it was not set.

I want to pass it if it IS set.

So `is not null` would be better - yes? (As I used it)

But could you - please - help me get my head around the difference between the two _options_ I used in the example flow?  
between `null` and `empty`  
There is also `set` and `not set`...... confusion awry.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 March 2023 23:57 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/4 "2023-03-03T23:57:16Z")

</div>

Maybe to better explain here is a _better_ laid out flow.

```auto
[{"id":"43b0a867366e9201","type":"inject","z":"0918ee609bf69fc7","name":"Wanted","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1730,"y":510,"wires":[["bf7938a4d1c0b9fc"]]},{"id":"24ea464f7f379813","type":"inject","z":"0918ee609bf69fc7","name":"Not wanted","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1730,"y":550,"wires":[["f7d96b70408812c1"]]},{"id":"716870566126c0ad","type":"debug","z":"0918ee609bf69fc7","name":"debug 65","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2320,"y":530,"wires":[]},{"id":"bf7938a4d1c0b9fc","type":"change","z":"0918ee609bf69fc7","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"This is the payload I want to get through","tot":"str"},{"t":"set","p":"important_piece","pt":"msg","to":"This needs to be parsed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1900,"y":510,"wires":[["239df70d331c7a67","6051957128a32947"]]},{"id":"f7d96b70408812c1","type":"change","z":"0918ee609bf69fc7","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"This is the payload. It isn't supposed to get through.","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1900,"y":550,"wires":[["239df70d331c7a67","6051957128a32947"]]},{"id":"239df70d331c7a67","type":"switch","z":"0918ee609bf69fc7","name":"","property":"important_piece","propertyType":"msg","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":2100,"y":530,"wires":[["716870566126c0ad"]]},{"id":"6051957128a32947","type":"switch","z":"0918ee609bf69fc7","name":"","property":"important_piece","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":2100,"y":490,"wires":[["eaf6e8ee778738c7"]]},{"id":"eaf6e8ee778738c7","type":"debug","z":"0918ee609bf69fc7","name":"debug 66","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2320,"y":490,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [4 March 2023 00:20 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/5 "2023-03-04T00:20:04Z")

</div>

Andrew, try this

```auto
[{"id":"43b0a867366e9201","type":"inject","z":"ed68efd020b754f0","name":"Wanted","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","_mcu":{"mcu":false},"x":130,"y":140,"wires":[["bf7938a4d1c0b9fc"]]},{"id":"24ea464f7f379813","type":"inject","z":"ed68efd020b754f0","name":"Not wanted","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","_mcu":{"mcu":false},"x":150,"y":300,"wires":[["f7d96b70408812c1"]]},{"id":"bf7938a4d1c0b9fc","type":"change","z":"ed68efd020b754f0","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"This is the payload I want to get through","tot":"str"},{"t":"set","p":"important_piece","pt":"msg","to":"This needs to be parsed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"_mcu":{"mcu":false},"x":300,"y":140,"wires":[["6051957128a32947"]]},{"id":"f7d96b70408812c1","type":"change","z":"ed68efd020b754f0","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"This is the payload. It isn't supposed to get through.","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"_mcu":{"mcu":false},"x":340,"y":300,"wires":[["6051957128a32947"]]},{"id":"6051957128a32947","type":"switch","z":"ed68efd020b754f0","name":"","property":"important_piece","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"false","repair":false,"outputs":2,"_mcu":{"mcu":false},"x":530,"y":200,"wires":[["a76f6126e533c8d8"],["eaf6e8ee778738c7"]]},{"id":"eaf6e8ee778738c7","type":"debug","z":"ed68efd020b754f0","name":"wanted","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","_mcu":{"mcu":false},"x":720,"y":220,"wires":[]},{"id":"a76f6126e533c8d8","type":"debug","z":"ed68efd020b754f0","d":true,"name":"not wanted","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","_mcu":{"mcu":false},"x":730,"y":160,"wires":[]}]

```

 ![Screenshot 2023-03-03 at 7.17.00 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fd5525915e4fb07312efbc6fcf254906dbaff2c8.png)

So what happens is when the msg enters the switch it looks to see if that object is null. If it I it goes out the top output but if it is not nulll (i.e. it exists) it goes out the second output of the switch.

As you will see when you try it, the wanted msg will pass thru to the debug while the not wanted will not.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 March 2023 08:09 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/6 "2023-03-04T08:09:24Z")

</div>

There still remains the question as to exactly what `empty` means. I am not certain of that myself.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [4 March 2023 08:23 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/7 "2023-03-04T08:23:41Z")

</div>

Again, thanks.

But as @Colin also asked:  
I am still not understanding what the difference between:  
`is not null`  
and  
`is not empty`  
The _HELP_ doesn't really cover it.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [4 March 2023 09:00 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/8 "2023-03-04T09:00:07Z")

</div>

![chrome_screenshot_1677920357060](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/1/d1860bb215ab1546498076fa71ee832d1f6a44c0.jpeg)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [4 March 2023 09:02 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/9 "2023-03-04T09:02:49Z")

</div>

I think you have posted that before.

Sorry I forgot it.

Top marks.

So how would they work in my example?  
Sorry for asking the dumb question.  
I need to get something cleared in my head.  
Until I can see this I am kinda stuck.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 March 2023 09:38 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/10 "2023-03-04T09:38:21Z")

</div>

Is 0 empty or not empty?

I am rather surprised by the answer

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/e/5e52115342d52f35b6bd945c432bd108bfae84b7.png)

The switch is set to check all the rules.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/a/aae122e3c91bad59049d1ecc00ece600787f040f.png)

```auto
[{"id":"06b2f69ed137e59f","type":"switch","z":"dd2ba972fa7bbf9b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"empty"},{"t":"nempty"},{"t":"null"},{"t":"nnull"},{"t":"else"}],"checkall":"true","repair":false,"outputs":5,"x":330,"y":920,"wires":[["cd6aaa98e70ea381"],["4597ec98110d8208"],["789b9d5cf13204ee"],["519c7f4159739ac6"],["c8df47687c6fe75c"]]},{"id":"cd6aaa98e70ea381","type":"debug","z":"dd2ba972fa7bbf9b","name":"Empty","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":840,"wires":[]},{"id":"c8df47687c6fe75c","type":"debug","z":"dd2ba972fa7bbf9b","name":"Otherwise","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":540,"y":1020,"wires":[]},{"id":"34e02a3186656fc4","type":"inject","z":"dd2ba972fa7bbf9b","name":"No payload","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":900,"wires":[["06b2f69ed137e59f"]]},{"id":"0ad1b3ccc517d2cf","type":"inject","z":"dd2ba972fa7bbf9b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{}","payloadType":"json","x":110,"y":940,"wires":[["06b2f69ed137e59f"]]},{"id":"1f6450ae67933b8d","type":"inject","z":"dd2ba972fa7bbf9b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[]","payloadType":"json","x":110,"y":980,"wires":[["06b2f69ed137e59f"]]},{"id":"789b9d5cf13204ee","type":"debug","z":"dd2ba972fa7bbf9b","name":"Null","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":920,"wires":[]},{"id":"e49d2c09f9e6cea5","type":"inject","z":"dd2ba972fa7bbf9b","name":"Empty string","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":130,"y":1020,"wires":[["06b2f69ed137e59f"]]},{"id":"4597ec98110d8208","type":"debug","z":"dd2ba972fa7bbf9b","name":"NOT Empty","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":550,"y":880,"wires":[]},{"id":"519c7f4159739ac6","type":"debug","z":"dd2ba972fa7bbf9b","name":"NOT null","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":540,"y":960,"wires":[]},{"id":"b19cb444e3b4e78c","type":"inject","z":"dd2ba972fa7bbf9b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":110,"y":860,"wires":[["06b2f69ed137e59f"]]}]

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [4 March 2023 09:44 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/11 "2023-03-04T09:44:21Z")

</div>

That is interesting.

When you inject the `[]` or `{}` you get TWO outputs.

How does that happen?  
Does the `switch` node create a new message?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 March 2023 09:45 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/12 "2023-03-04T09:45:36Z")

</div>

> [@Trying\_to\_learn](#):
>
> When you inject the `[]` or `{}` you get TWO outputs.
> 
> How does that happen?

As I said:

> [@Colin](#):
>
> The switch is set to check all the rules.

So `[]` is both empty and not null.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [4 March 2023 09:46 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/13 "2023-03-04T09:46:46Z")

</div>

Sorry.

My parsing system is not working just now.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 March 2023 09:49 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/14 "2023-03-04T09:49:53Z")

</div>

More interesting is the fact there is only one output for `0`

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [4 March 2023 09:51 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/15 "2023-03-04T09:51:58Z")

</div>

~~I am now missing something else.~~

~~Why?~~

~~To me that is understandable.~~

It is not _empty_ **AND** it is not _null_ ..... ( **AND** _otherwise_?)

Oh, so they should get two or more outputs also - yes?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [4 March 2023 10:12 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/16 "2023-03-04T10:12:06Z")

</div>

Interesting.

@Trying_to_learn  
you could test for undefined, or use JSONata $exists()

```auto
[{"id":"43b0a867366e9201","type":"inject","z":"65617ffeb779f51c","name":"Wanted","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":460,"wires":[["bf7938a4d1c0b9fc"]]},{"id":"bf7938a4d1c0b9fc","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"This is the payload I want to get through","tot":"str"},{"t":"set","p":"important_piece","pt":"msg","to":"This needs to be parsed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":460,"wires":[["6051957128a32947","7879b086fb12a758"]]},{"id":"6051957128a32947","type":"switch","z":"65617ffeb779f51c","name":"","property":"important_piece","propertyType":"msg","rules":[{"t":"istype","v":"undefined","vt":"undefined"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":510,"y":440,"wires":[[],["eaf6e8ee778738c7"]]},{"id":"7879b086fb12a758","type":"switch","z":"65617ffeb779f51c","name":"","property":"$exists(important_piece)","propertyType":"jsonata","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":510,"y":540,"wires":[["eaf6e8ee778738c7"]]},{"id":"f7d96b70408812c1","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"This is the payload. It isn't supposed to get through.","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":500,"wires":[["6051957128a32947","7879b086fb12a758"]]},{"id":"eaf6e8ee778738c7","type":"debug","z":"65617ffeb779f51c","name":"debug 66","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":440,"wires":[]},{"id":"24ea464f7f379813","type":"inject","z":"65617ffeb779f51c","name":"Not wanted","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":500,"wires":[["f7d96b70408812c1"]]}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [4 March 2023 10:42 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/17 "2023-03-04T10:42:32Z")

</div>

Here is a write up that may (?) help you understand

> **[JavaScript Check Empty String – Checking Null or Empty in JS](https://www.freecodecamp.org/news/javascript-check-empty-string-checking-null-or-empty-in-js/amp/)**
>
> There are a number of reasons why you might need to check if a string is empty or not. One of the most important reasons is when you're retrieving data from a database, API, or input field. In this article, you will learn how to check if a sting is

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 March 2023 10:46 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/18 "2023-03-04T10:46:27Z")

</div>

The 'check all rules' doesn't apply to Otherwise, it would be silly if it did.

The anomaly with zero is that it does not match `is empty`, but it doesn't match `is not empty` either. So zero is not 'empty' but it is also not 'not empty', which doesn't make sense to me. A sort of anti Schrodinger effect. That sounds like a bug to me.  
In fact it isn't only zero this applies to, any number gives the same result.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [4 March 2023 15:51 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/19 "2023-03-04T15:51:41Z")

</div>

From help

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

"0" works as expected.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 March 2023 16:04 UTC](https://discourse.nodered.org/t/switch-node-question-about-options/76086/20 "2023-03-04T16:04:10Z")

</div>

Ah yes, RTFM.  
Though actually the FM is not complete, as it goes on to say  
"Neither rule will pass if the property being tested has a boolean, null or undefined value."  
That list should include numeric.

[Next page](https://discourse.nodered.org/t/switch-node-question-about-options/76086.md?page=2)
