# Form action validate() vs. validate\_slotxyz()

**URL:** <https://forum.rasa.com/t/form-action-validate-vs-validate-slotxyz/20253>\
**Category:** Rasa Open Source\
**Created:** [October 23, 2019, 8:42pm UTC](https://forum.rasa.com/t/form-action-validate-vs-validate-slotxyz/20253 "2019-10-23T20:42:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmm3bbb](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mmm3bbb](https://forum.rasa.com/u/mmm3bbb)\
**Post date:** [October 23, 2019, 8:42pm UTC](https://forum.rasa.com/t/form-action-validate-vs-validate-slotxyz/20253/1 "2019-10-23T20:42:02Z")

</div>

I can’t find documentation for validate(), but I find it more general (and therefore more useful) than validate\_slotxyz().

Is there danger in using validate() and is validate\_slotxyz() just a convenience function?

---

<div class="post-metadata">

**Author:** ![Tanja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tanja/32/4696_2.png) [@Tanja](https://forum.rasa.com/u/Tanja)\
**Post date:** [October 24, 2019, 7:29am UTC](https://forum.rasa.com/t/form-action-validate-vs-validate-slotxyz/20253/2 "2019-10-24T07:29:55Z")

</div>

The `validate` function does the following:

```auto
Extract and validate value of requested slot.

If nothing was extracted reject execution of the form action.
Subclass this method to add custom validation and rejection logic.

```

So, the `validate` function does not only validate the value that is set, but it also checks if the user may want to reject the form and break out from it. If the requested slot was filled, the `validate` function is calling the `validate_slotxyz` functions.

So, if you just want to update the validation of the set value, I would recommend to overwrite the `validate_slotxyz` function. If you want to add more/change the rejection logic, you should overwrite the `validate` function.

---

<div class="post-metadata">

**Author:** ![mmm3bbb](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mmm3bbb](https://forum.rasa.com/u/mmm3bbb)\
**Post date:** [October 24, 2019, 5:04pm UTC](https://forum.rasa.com/t/form-action-validate-vs-validate-slotxyz/20253/3 "2019-10-24T17:04:31Z")

</div>

Thanks @Tanja. That makes sense. I was wondering why rejections stopped working and now I know why!

---

<div class="post-metadata">

**Author:** ![mmm3bbb](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mmm3bbb](https://forum.rasa.com/u/mmm3bbb)\
**Post date:** [November 10, 2019, 8:57pm UTC](https://forum.rasa.com/t/form-action-validate-vs-validate-slotxyz/20253/4 "2019-11-10T20:57:03Z")

</div>

@Tanja I’m still a little unclear about when validate vs validate\_slotxyz is actually called. It seems that validate\_slottxyz will only be called when slot\_mappings() conditions are met. let’s say I have:

```
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
    return {
        "slot1": self.from_entity(entity="entity_for_slot1", intent="inform"),
        "slot2": self.from_entity(entity="entity_for_slot2", intent="inform")
    }

```

Let’s then say I am in the form for slot1 and then it extracts entity\_for\_slot1 entity, but let’s say it classifies the intent wrong. Since this mapping “fails”, it won’t call validate\_slot1(). However, it will call validate().

If it actually matches the entity and the intent above, then it will call validate\_slot1() and will not call validate().

That’s what seems to be happening. Can you confirm?

---

<div class="post-metadata">

**Author:** ![Tanja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tanja/32/4696_2.png) [@Tanja](https://forum.rasa.com/u/Tanja)\
**Post date:** [November 12, 2019, 7:43am UTC](https://forum.rasa.com/t/form-action-validate-vs-validate-slotxyz/20253/5 "2019-11-12T07:43:33Z")

</div>

Yes, that is exactly what is happening.
