Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you clarify an intended way of validation? #19

Open
streamx3 opened this issue May 28, 2020 · 1 comment
Open

Could you clarify an intended way of validation? #19

streamx3 opened this issue May 28, 2020 · 1 comment

Comments

@streamx3
Copy link

streamx3 commented May 28, 2020

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
Copy link
Owner

porimol commented May 28, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants