# How to validate entities?

**URL:** <https://forum.rasa.com/t/how-to-validate-entities/47204>\
**Category:** Tutorials, Resources & Videos\
**Tags:** rasa\
**Created:** [August 25, 2021, 2:54pm UTC](https://forum.rasa.com/t/how-to-validate-entities/47204 "2021-08-25T14:54:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![manoj\_kumar](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@manoj\_kumar](https://forum.rasa.com/u/manoj_kumar)\
**Post date:** [August 25, 2021, 2:54pm UTC](https://forum.rasa.com/t/how-to-validate-entities/47204/1 "2021-08-25T14:54:50Z")

</div>

Hi,

I am trying to create a bot regarding weather. I have called weather API and going well. But I have doubts about how can we validate the “location” entity.

Example:

```auto
Bot: which location do you want to check for?
You: Mumbai 
Bot: Haze in Mumbai and temperature is 27 degrees Celcius and Humidity 89%

```

And if give “12345” it should render “please enter the correct location”.

```auto
Bot: which location do you want to check for?
You: 123456
Bot: please enter the correct location

```

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [August 25, 2021, 3:02pm UTC](https://forum.rasa.com/t/how-to-validate-entities/47204/2 "2021-08-25T15:02:58Z")

</div>

@manoj_kumar Hope you have seen this [Forms](https://rasa.com/docs/rasa/forms/#validating-form-input) ?

---

<div class="post-metadata">

**Author:** ![manoj\_kumar](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@manoj\_kumar](https://forum.rasa.com/u/manoj_kumar)\
**Post date:** [August 26, 2021, 1:35pm UTC](https://forum.rasa.com/t/how-to-validate-entities/47204/3 "2021-08-26T13:35:01Z")

</div>

Yes @nik202 , But I getting confused while implementing the validation.

class ActionWeather(Action):

```
def name(self) -> Text:
    return "action_weather"

def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
    
    loc=tracker.get_slot('location')
    temp = int(Weather(loc)['temp']-273)
    hum = int(Weather(loc)['humidity'])
    cond = Weather_Condition()[0]['description']
    dispatcher.utter_message(template="utter_temp", LOC=loc, temp=temp, hum=hum, condition=cond)
       
    #return [SlotSet('location',loc)]
    return []

```

class ValidateWeatherForm(FormValidationAction):

```
    def name(self) -> Text:
        return "validate_weather_form"
    
    def validate_location(
    self,
    slot_value: Text,
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: DomainDict,
) ->Dict[Text, Any]:
        
        #loc=tracker.get_slot('location')
        #if slot_value and slot_value.lower() in loc:
            #if loc.isalpha() == True:
                #return {"location": slot_value}
        #if not loc.isalpha() == True:
            #dispatcher.utter_message(template = "utter_invalid")
            #return{"location": None}
        if (str(slot_value.isalpha()))==False:
            dispatcher.utter_message(template="utter_invalid")
            return{"location": None}
        else:
            return {"location": slot_value}
```

---

<div class="post-metadata">

**Author:** ![manoj\_kumar](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@manoj\_kumar](https://forum.rasa.com/u/manoj_kumar)\
**Post date:** [August 27, 2021, 4:31am UTC](https://forum.rasa.com/t/how-to-validate-entities/47204/4 "2021-08-27T04:31:43Z")

</div>

Hi @nik202,

Can I use spacy to validate the location name?

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [August 30, 2021, 11:35am UTC](https://forum.rasa.com/t/how-to-validate-entities/47204/5 "2021-08-30T11:35:14Z")

</div>

@manoj_kumar means ?
