# How to validate multiple slots at once?

**URL:** <https://forum.rasa.com/t/how-to-validate-multiple-slots-at-once/13819>\
**Category:** Rasa Open Source\
**Created:** [August 1, 2019, 1:57pm UTC](https://forum.rasa.com/t/how-to-validate-multiple-slots-at-once/13819 "2019-08-01T13:57:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alihejazi](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@alihejazi](https://forum.rasa.com/u/alihejazi)\
**Post date:** [August 1, 2019, 1:57pm UTC](https://forum.rasa.com/t/how-to-validate-multiple-slots-at-once/13819/1 "2019-08-01T13:57:13Z")

</div>

Hi all,

Hope you guys are doing well!

I have a form action which takes in, say for example, slots x, y, and z.

I call validate\_x to validate x.

But I want to validate slots y and z together. If either is wrong, or both are wrong, I ask for both again.

Is there any way to do this?

I’ve seen some people use methods called “validate” or “validate\_slots” but I don’t quite understand their usage, and how to use them, as I have not seen an official example for them.

Any help is greatly appreciated!

Thanks everyone, and good work to the team at Rasa 🙂

---

<div class="post-metadata">

**Author:** ![IgNoRaNt23](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ignorant23/32/8029_2.png) [@IgNoRaNt23](https://forum.rasa.com/u/IgNoRaNt23)\
**Post date:** [August 2, 2019, 6:22am UTC](https://forum.rasa.com/t/how-to-validate-multiple-slots-at-once/13819/2 "2019-08-02T06:22:28Z")

</div>

validate\_x:

if y is set:

do validation

else

return slot\_x : value

And the same with x and y exchanged. If you want both to be set in the same message, you can return None if only on is set. Or as above just wait till both slots are set. You might set either slot in the others validate method

---

<div class="post-metadata">

**Author:** ![alihejazi](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@alihejazi](https://forum.rasa.com/u/alihejazi)\
**Post date:** [August 2, 2019, 9:34am UTC](https://forum.rasa.com/t/how-to-validate-multiple-slots-at-once/13819/3 "2019-08-02T09:34:03Z")

</div>

Thanks for your response. I am actually picking up both slots (say slot1 and slot2) from two different messages, so one after another. Basically right now I resolve the problem by calling validate\_slot2, doing my validation for 1 and 2 together and if any is wrong, set both to None again so they’re asked for again.

But I’m just wondering if there’s a neater method instead of having to do this with the final slot validator method (validate\_slot2).

Like, I’ve seen some people use “validate” or “validate\_slots” as a method but I don’t get them - could they be used in this circumstance, as like a generic validate method to validate multiple/all slots at once, or are they used for something else?

If you don’t know it’s not a huge deal, as my approach currently works as it is right now… I’m just wondering if there’s something a tad neater 🙂

Thanks!

---

<div class="post-metadata">

**Author:** ![IgNoRaNt23](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ignorant23/32/8029_2.png) [@IgNoRaNt23](https://forum.rasa.com/u/IgNoRaNt23)\
**Post date:** [August 2, 2019, 10:43am UTC](https://forum.rasa.com/t/how-to-validate-multiple-slots-at-once/13819/4 "2019-08-02T10:43:20Z")

</div>

As I see it, I gave a solution to that problem. If ‘do validation’ is the same function called with the values from slot\_x and slot\_y it works perfectly fine that way.

So, it doesnt matter in which order the slots are entered. But maybe I dont get what you want.

---

<div class="post-metadata">

**Author:** ![kothiyayogesh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kothiyayogesh/32/324_2.png) [@kothiyayogesh](https://forum.rasa.com/u/kothiyayogesh)\
**Post date:** [January 6, 2020, 10:36am UTC](https://forum.rasa.com/t/how-to-validate-multiple-slots-at-once/13819/5 "2020-01-06T10:36:43Z")

</div>

Check this [discussion thread](http://forum.rasa.com/t/form-action-validate-vs-validate-slotxyz/20253/2).
