# Cannot Validate Slot

**URL:** <https://forum.rasa.com/t/cannot-validate-slot/40745>\
**Category:** Rasa Open Source\
**Created:** [March 1, 2021, 2:57pm UTC](https://forum.rasa.com/t/cannot-validate-slot/40745 "2021-03-01T14:57:34Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [March 1, 2021, 2:57pm UTC](https://forum.rasa.com/t/cannot-validate-slot/40745/1 "2021-03-01T14:57:34Z")

</div>

Hello.

I am trying to validate a `username` slot by looking in a database if it exists. The query works well and outputs as expected.

This is the relevant method of my FormValidationAction:

```auto
    async def validate_username(self, value, dispatcher, tracker, domain):
        username = value.lower()

        db = DatabaseConnection()
        count = db.count('user_info', f"Username = '{username}'")
        db.disconnect()

        if count == 1:
            return {'username', username}

        else:
            utterance = get_utter_from_lang(
                tracker,
                'Sorry, {} is not a registered user.'.format(username),
                'Désolé, {} n\'est pas un utilisateur enregistré.'.format(username),
                'عذرًا، {} ليس مستخدمًا مسجلاً'.format(username),
                'Ներողություն, {} - ը գրանցված օգտվող չէ:'.format(username)
            )
            dispatcher.utter_message(utterance)
            return {'username', None}

```

So, if the username is found in the database, `count` is equal to `1` and the `username` slot should be set with the given value. If the username was not found, `count` is equal to `0`, so `username` should be set to `None` (or _null_), and the bot asks for the username again.

But, in both cases, I get this error on the action server:

```auto
E:\...\_venv\lib\site-packages\rasa_sdk\forms.py:858: UserWarning: Cannot validate `password`: make sure the validation method returns the correct output.
  warnings.warn(

```

and the bot sets the slot and continues the form anyway.

I don’t know if it’s relevant, but that’s how it’s defined in `domain.yml`:

```auto
forms:
  form_query_quota:
    username:
    - intent_name: None
      not_intent: stop
      type: from_text

```

---

<div class="post-metadata">

**Author:** ![alexyuwen](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/alexyuwen/32/13250_2.png) [@alexyuwen](https://forum.rasa.com/u/alexyuwen)\
**Post date:** [March 1, 2021, 6:16pm UTC](https://forum.rasa.com/t/cannot-validate-slot/40745/2 "2021-03-01T18:16:39Z")

</div>

You are currently returning sets rather than dicts since you have used commas instead of colons. Validation actions must return dictionaries.

---

<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:** [March 1, 2021, 6:21pm UTC](https://forum.rasa.com/t/cannot-validate-slot/40745/3 "2021-03-01T18:21:24Z")

</div>

I am so dumb, I did not notice that. Thank you!
