porimol / countryinfo

A python module for returning data about countries, ISO info and states/provinces within them.
MIT License
139 stars 44 forks source link

Could you clarify an intended way of validation? #19

Open streamx3 opened 4 years ago

streamx3 commented 4 years ago

I work with few databases, and I can't control the exact country name used. Hence, I need to validate DB names vs names in your library. For example: 'Polska' instead of 'Poland'

What I came up with is:

def isCountryNameValid(name: str) -> bool:
    rv = True
    try:
        c = CountryInfo(name)
        data = c.native_name()
    except KeyError:
        rv = False
    return rv

If you have something better in mind (and I couldn't figure that out) -- could you add to API documentation? Otherwise, maybe you'd like to add it, or share your view and I could try implement if myself :)

porimol commented 4 years ago

Hi @streamx3 ,

I think you are facing alternative spellings/localized issue with country name! What you came up looks good, but there could be another better work around like localized the country name and add it into json dataset. or from your DB side you can also add another field name like eng_country_name.