# Input box validation failure

**URL:** <https://discourse.nodered.org/t/input-box-validation-failure/43513>\
**Category:** Developing Nodes\
**Created:** [1 April 2021 12:57 UTC](https://discourse.nodered.org/t/input-box-validation-failure/43513 "2021-04-01T12:57:59Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [1 April 2021 12:57 UTC](https://discourse.nodered.org/t/input-box-validation-failure/43513/1 "2021-04-01T12:57:59Z")

</div>

I've spotted an annoying problem with [node-red-contrib-google-smarthome](https://github.com/mikejac/node-red-contrib-google-smarthome) where the node config has two options, selectable via a tick box;

The first option is to use google authentication (preferred option)

![google pass](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/d/adfdf7d76b975e3a54abe4431d93ec07ed37e00f.jpeg)

The second option, by unticking the box, users can use a simple password

![google local](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/6/3627eea76d81c50d2a830ae0d81732e88ef6558c.jpeg)

The problem is that if the first option is selected (Google login), the second option's input boxes would be left blank (as we aren't using the second option).  
But because they are blank, node-RED will not verify the input boxes, and as you can see in the screenshot above, node-RED colours the input box outlines red, places a red triangle on the node, and a popup saying that the node is not correctly configured (despite option 1 being selected).

![error](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fd9efb37d2acb008771d350b3a5ea790ab7f0927.jpeg)

However despite this annoyance, [node-red-contrib-google-smarthome](https://github.com/mikejac/node-red-contrib-google-smarthome) works very well 👍

I've tried adding a input box placeholder for the fields, which didn't help, and have opened an [issue](https://github.com/mikejac/node-red-contrib-google-smarthome/issues/123) with the author, but wondered if anyone knows the best way to deal with this pls?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [1 April 2021 13:35 UTC](https://discourse.nodered.org/t/input-box-validation-failure/43513/2 "2021-04-01T13:35:53Z")

</div>

the author would need to use a custom validator that takes into account if they are active or not.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [1 April 2021 13:37 UTC](https://discourse.nodered.org/t/input-box-validation-failure/43513/3 "2021-04-01T13:37:41Z")

</div>

I've been reading the validation section in  
[https://nodered.org/docs/creating-nodes/properties](https://nodered.org/docs/creating-nodes/properties)  
Are there any specific examples which come to mind, for this problem.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [1 April 2021 13:45 UTC](https://discourse.nodered.org/t/input-box-validation-failure/43513/4 "2021-04-01T13:45:22Z")

</div>

Well the docs is a good place to start - [Node properties : Node-RED](https://nodered.org/docs/creating-nodes/properties#property-validation)

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [1 April 2021 18:08 UTC](https://discourse.nodered.org/t/input-box-validation-failure/43513/5 "2021-04-01T18:08:33Z")

</div>

As I said above, I've read the documentation, but the example given in the docs is quite complex, and does not describe the context of how it's implemented.  
I've also looked at a number of contrib nodes for a basic example, but it appears to be rarely used.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [1 April 2021 18:26 UTC](https://discourse.nodered.org/t/input-box-validation-failure/43513/6 "2021-04-01T18:26:56Z")

</div>

It just needs to be a function that returns Boolean true (for valid) or false.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [1 April 2021 18:30 UTC](https://discourse.nodered.org/t/input-box-validation-failure/43513/7 "2021-04-01T18:30:38Z")

</div>

Paul,  
Unfortunately I cannot check their npm version now ...  
But looking at their github demo version [code](https://github.com/mikejac/node-red-contrib-google-smarthome/blob/a4897a326215d3ab2b2888d56969109fef0213af/google-smarthome.html#L196), I would expect their current existing validation function to work correctly at first sight. Since it already takes into account the checkbox value. Perhaps this is not available in your npm version yet??

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [1 April 2021 18:39 UTC](https://discourse.nodered.org/t/input-box-validation-failure/43513/8 "2021-04-01T18:39:53Z")

</div>

These validators have been added on 7 october on Github (see this [commit](https://github.com/mikejac/node-red-contrib-google-smarthome/commit/e7adf0de378cd33f619d8b8f3069478673727652#diff-df897dc85897b43b5fede0a31f34b3f67f0f6cb45dc75d7890f5232f4369ce8b)).

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [1 April 2021 18:59 UTC](https://discourse.nodered.org/t/input-box-validation-failure/43513/9 "2021-04-01T18:59:56Z")

</div>

Thanks Bart, I'm using npm v6.14.11, tried on 2 machines, and the author can also replicate the issue.  
Using the current version of smarthome (v0.0.64), the validation is throwing up the warning (screenshots in [the git issue](https://github.com/mikejac/node-red-contrib-google-smarthome/issues/123)).

I guess I'll leave it to someone more competent than me to fix 😬  
I was just trying to contribute and learn a little along the way...

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [1 April 2021 19:17 UTC](https://discourse.nodered.org/t/input-box-validation-failure/43513/10 "2021-04-01T19:17:21Z")

</div>

Sorry Paul,  
Cannot debug your issue...  
Just answering from my smartphone...

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [1 April 2021 19:30 UTC](https://discourse.nodered.org/t/input-box-validation-failure/43513/11 "2021-04-01T19:30:54Z")

</div>

No worries, I'm sure it will get fixed.  
You have helped me by pointing me to the validation functions, at least I can now see how validation should work!

---

<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:** [31 May 2021 19:31 UTC](https://discourse.nodered.org/t/input-box-validation-failure/43513/12 "2021-05-31T19:31:03Z")

</div>

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