# Can't you add "===" to the switch node?

**URL:** <https://discourse.nodered.org/t/cant-you-add-to-the-switch-node/70754>\
**Category:** Feature Requests\
**Created:** [17 November 2022 07:32 UTC](https://discourse.nodered.org/t/cant-you-add-to-the-switch-node/70754 "2022-11-17T07:32:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mitubato](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mitubato/32/52887_2.png) [@mitubato](https://discourse.nodered.org/u/mitubato)\
**Post date:** [17 November 2022 07:32 UTC](https://discourse.nodered.org/t/cant-you-add-to-the-switch-node/70754/1 "2022-11-17T07:32:43Z")

</div>

Any plans to add "===" for exact match in switch node?  
The purpose can be achieved by using two switch nodes or using a function node, but I thought it would be smarter to include it in the switch node.

Now I am using Node-red3.0.2 and NJ18.4.0.

---

<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:** [17 November 2022 08:21 UTC](https://discourse.nodered.org/t/cant-you-add-to-the-switch-node/70754/2 "2022-11-17T08:21:50Z")

</div>

Welcome to the forum @mitubato

I am interested in what use case you have that would benefit from that?

---

<div class="post-metadata">

**Author:** ![mitubato](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mitubato/32/52887_2.png) [@mitubato](https://discourse.nodered.org/u/mitubato)\
**Post date:** [17 November 2022 08:39 UTC](https://discourse.nodered.org/t/cant-you-add-to-the-switch-node/70754/3 "2022-11-17T08:39:15Z")

</div>

Hello @Colin  
We intend to use it to check input values.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [17 November 2022 08:53 UTC](https://discourse.nodered.org/t/cant-you-add-to-the-switch-node/70754/4 "2022-11-17T08:53:32Z")

</div>

The reason we chose not to include that is because for a low-code programming tool, explaining the difference between `==` and `===` is not that simple to do.

We could add something like `is exactly` which is a bit more accessible.

---

<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:** [17 November 2022 08:57 UTC](https://discourse.nodered.org/t/cant-you-add-to-the-switch-node/70754/5 "2022-11-17T08:57:30Z")

</div>

> [@mitubato](#):
>
> We intend to use it to check input values

I wondered why you need === rather than ==.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [17 November 2022 09:09 UTC](https://discourse.nodered.org/t/cant-you-add-to-the-switch-node/70754/6 "2022-11-17T09:09:11Z")

</div>

You could check for 'is type of' ? Or matches regex with a pattern

---

<div class="post-metadata">

**Author:** ![mitubato](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mitubato/32/52887_2.png) [@mitubato](https://discourse.nodered.org/u/mitubato)\
**Post date:** [17 November 2022 09:30 UTC](https://discourse.nodered.org/t/cant-you-add-to-the-switch-node/70754/7 "2022-11-17T09:30:41Z")

</div>

The difficulty of expression is something I also thought of when I looked at the code.

---

<div class="post-metadata">

**Author:** ![mitubato](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mitubato/32/52887_2.png) [@mitubato](https://discourse.nodered.org/u/mitubato)\
**Post date:** [17 November 2022 09:42 UTC](https://discourse.nodered.org/t/cant-you-add-to-the-switch-node/70754/8 "2022-11-17T09:42:55Z")

</div>

I am at a loss to answer the question of necessity, but I thought it might be useful if it were available.  
I think it makes sense to use toString() or parseInt() to determine the type.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [17 November 2022 15:26 UTC](https://discourse.nodered.org/t/cant-you-add-to-the-switch-node/70754/9 "2022-11-17T15:26:10Z")

</div>

> [@mitubato](#):
>
> The purpose can be achieved by using two switch nodes

It can be done with just one node by setting the rule to `JSONata exp` and using a rule of the form

`($type(payload) = "string") and (payload = "foobar")`

---

<div class="post-metadata">

**Author:** ![mitubato](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mitubato/32/52887_2.png) [@mitubato](https://discourse.nodered.org/u/mitubato)\
**Post date:** [18 November 2022 04:07 UTC](https://discourse.nodered.org/t/cant-you-add-to-the-switch-node/70754/10 "2022-11-18T04:07:12Z")

</div>

ありがとう。  
参考にさせていただきます。

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 January 2023 04:07 UTC](https://discourse.nodered.org/t/cant-you-add-to-the-switch-node/70754/11 "2023-01-17T04:07:52Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
