# Reset slots during form validation

**URL:** <https://forum.rasa.com/t/reset-slots-during-form-validation/43116>\
**Category:** Rasa Open Source\
**Created:** [May 2, 2021, 8:54am UTC](https://forum.rasa.com/t/reset-slots-during-form-validation/43116 "2021-05-02T08:54:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SimoCanc](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@SimoCanc](https://forum.rasa.com/u/SimoCanc)\
**Post date:** [May 2, 2021, 8:54am UTC](https://forum.rasa.com/t/reset-slots-during-form-validation/43116/1 "2021-05-02T08:54:01Z")

</div>

Hi all,  
I would like to know how I could reset slots during form validation.  
I am trying to validate the slot `pizza_type` by:

```
class ValidateStandardForm(FormValidationAction): 
  def name(self) -> Text:
       return "validate_standard_form" 

   def validate_pizza_type(self,   
                            slot_value: Any,
                            dispatcher: CollectingDispatcher,
                            tracker: Tracker,
                            domain: DomainDict) -> List[Dict[Text, Any]]:

    pizza_type_db = ['salami', 'tuna', 'wurstel', 'pepperoni']
    slot_pizza_type = tracker.get_slot("pizza_type")
    flag = 0
   
    for pizza in slot_value:
        if pizza not in pizza_type_db:
            flag = 1
            dispatcher.utter_message(f"!!!{pizza} is not a valid pizza type!!!")
    if flag == 1:
        return [SlotSet("pizza_type", []), SlotSet("pizza_quantity", [])]
    else:
        return [{"pizza_type": slot_pizza_type}]

```

I have noticed that is not possible to reset the slots `pizza_type` and `pizza_quantity`using` SlotSet()`, also the action server gives this warning message:

```
UserWarning: Cannot validate `pizza_type`: make sure the validation method returns the correct output.
  f"Cannot validate `{slot_name}`: make sure the validation method "
```

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [May 2, 2021, 8:37pm UTC](https://forum.rasa.com/t/reset-slots-during-form-validation/43116/2 "2021-05-02T20:37:45Z")

</div>

First, you use the format `{slot: value}` in slot validation and `[SlotSet(slot, value)]` in `run()`.

If you want to unset a slot in `run()`, use `None` with `SlotSet()`:

```auto
if flag == 1:
    return [SlotSet("pizza_type", None), SlotSet("pizza_quantity", None)]
else:
    return [SlotSet("pizza_type", slot_pizza_type)]

```

If you want to unset a slot in validation, use a dictionary:

```auto
if flag == 1:
    return {"pizza_type": None, "pizza_quantity": None}
else:
    return {"pizza_type": slot_pizza_type}

```
