Skip to content

Adds ES doi / nie / cif / nif #121

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

Merged
merged 1 commit into from
May 20, 2019
Merged

Adds ES doi / nie / cif / nif #121

merged 1 commit into from
May 20, 2019

Conversation

kingbuzzman
Copy link
Contributor

@kingbuzzman kingbuzzman commented Apr 29, 2019

- Adds Locale() to abstract away the region.

  • Adds Spanish nie / nif / cif / doi validation

@kingbuzzman
Copy link
Contributor Author

kingbuzzman commented Apr 29, 2019

@kvesteri how do i compile the docs so i can test them out? I keep getting an error about "sphinx.ext.pngmath" not being found. What version are you using?

@kingbuzzman kingbuzzman changed the title [WIP] Adds ES ssn, adds better locale support Adds ES ssn, adds better locale support Apr 30, 2019
@kvesteri
Copy link
Collaborator

kvesteri commented May 8, 2019

Thanks for the PR. What is the benefit of the Locale class?

I would rather use syntax of something like:

import validators

validators.fi.business_id('0112038-9')

validators.es.cif('B25162520')

rather than having to always initialize a new Locale object. Another problem with the Locale object is that it is easily confused with Bable Locale object.

@kingbuzzman
Copy link
Contributor Author

@kvesteri I mean the whole idea is to abstract away the whole i18n and make it seamless. The way i envision this is: (this may be a horrible example, but just attempt to get by point across)

validators/temperature.py

@validator
def livable_temperature(temp):
     """Assuming celcius"""
     return 50 > temp > -30

validators/i18n/us/temperature.py

@validator
def us_livable_temperature(temp):
     """When will the US get with the times?!"""
     return 122 > temp > -22

in your code

from validators import Locale

def is_valid_temp(temp):
    validators = Locale()
    return validators.livable_temperature(temp)

is_valid_temp(75)  # if in the US  # this is `True`
is_valid_temp(25)  # if ANYWHERE else in the world  # this is `True`

Put it simply, the idea is to be able to not need to know the locale in order to use it. Its seamless to the user, the user simply just uses the validator, we do the heavy lifting underneath the covers.

If you're concerned with having the name Locale as it can be confused with Bable Locale. The user can simply do from validators import Locale as ValidatorLocale or something around those lines. ... Does that make any sense? I can try again with another horrible example :P

@kvesteri
Copy link
Collaborator

kvesteri commented May 8, 2019

I'm just not convinced by either this branch or the example you gave that the having a Locale class would be the way to go. The whole point of this library is to have a collection of immutable functions. I'd prefer not have anything containing a state.

@kingbuzzman
Copy link
Contributor Author

@kvesteri Hey, this is your repo. You're the benevolent dictator here. I will remove the Locale and leave the rest of the validation code.

@kingbuzzman
Copy link
Contributor Author

kingbuzzman commented May 8, 2019

@kvesteri can I remove the es_ and fi_ prefixes? Im for keeping the validators.i18n.<countrycode> -- just the prefixes seem redundant.

@kingbuzzman kingbuzzman changed the title Adds ES ssn, adds better locale support Adds ES doi / nie / cif / nif May 8, 2019
@kingbuzzman
Copy link
Contributor Author

@kvesteri friendly ping.

@kingbuzzman
Copy link
Contributor Author

@kvesteri can you let me know when you publish this please? I have a PR over at joke2k/faker#959 that needs a version. Thanks.

@kvesteri
Copy link
Collaborator

Already released (0.13.0)

@kingbuzzman
Copy link
Contributor Author

@kvesteri ps. https://validators.readthedocs.io/en/latest/ doc looks old.

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

Successfully merging this pull request may close these issues.

2 participants