# How to do input validation?

**URL:** <https://discourse.nodered.org/t/how-to-do-input-validation/67623>\
**Category:** General\
**Created:** [12 September 2022 19:08 UTC](https://discourse.nodered.org/t/how-to-do-input-validation/67623 "2022-09-12T19:08:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![campot05](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@campot05](https://discourse.nodered.org/u/campot05)\
**Post date:** [12 September 2022 19:08 UTC](https://discourse.nodered.org/t/how-to-do-input-validation/67623/1 "2022-09-12T19:08:39Z")

</div>

Guys, I'm just learning, please tell me how can I check the input data? I need to check the input data, whether the phone number is correct according to the following parameters:

- format is "380..."
- only numbers
- number length 12 digits

and if the data is correct, then I pass the information to the next process.

Which node can solve this problem? I tried through the switch, but I didn’t get anything ☹ Tell me where you can at least see examples.

---

<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:** [12 September 2022 19:28 UTC](https://discourse.nodered.org/t/how-to-do-input-validation/67623/2 "2022-09-12T19:28:56Z")

</div>

Hi and welcome.

The switch will work if you set a match regex `^380\d{9}$`  
^startof string  
\d any digit  
{9} 9 times  
$ end of string

---

<div class="post-metadata">

**Author:** ![campot05](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@campot05](https://discourse.nodered.org/u/campot05)\
**Post date:** [12 September 2022 19:39 UTC](https://discourse.nodered.org/t/how-to-do-input-validation/67623/3 "2022-09-12T19:39:29Z")

</div>

Thanks a lot!  
where should it be written?(  
And is it possible to solve this problem in any other way?

---

<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:** [12 September 2022 20:09 UTC](https://discourse.nodered.org/t/how-to-do-input-validation/67623/4 "2022-09-12T20:09:19Z")

</div>

In the input field once you select match regex in he dropdown selection box, in the rules section.

Yes many ways, you could do it in a function node with javascript, and there are contrib nodes for validating input/json/xml/etc.  
[https://flows.nodered.org/search?term=validate](https://flows.nodered.org/search?term=validate)

---

<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:** [11 November 2022 20:10 UTC](https://discourse.nodered.org/t/how-to-do-input-validation/67623/5 "2022-11-11T20:10:10Z")

</div>

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