How to validate multiple slots at once?

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 :slight_smile:

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

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 :slight_smile:

Thanks!

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.

Check this discussion thread.