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

[Refactor proposal] Use countrycode instead of locale for some validators #2171

Open
WikiRik opened this issue Feb 1, 2023 · 1 comment
Open

Comments

@WikiRik
Copy link
Member

WikiRik commented Feb 1, 2023

I will update this later with a proper table, but some validators like isMobilePhone and isLicensePlate do not need a specified locale since the values are not dependent on the language used but only the country. For others, like isAlpha, we should remain using the locales. In any case country codes and locales should not be mixed (like in isIdentityCard)

What I have in mind is that we allow the countrycodes to be used first and that those are mapped to the current locales so both are supported but it's easy to remove the locales in a later major version. (I will provide an example in the updated issue)

My idea is that this is done after #1874 has been finished and we have split the test cases in different files. That makes it easier to see which tests are for the new syntax and which ones of the legacy syntax (see https://github.com/validatorjs/validator.js/blob/master/test/validators/isAfter.test.js for example). I would not recommend to do this in combination with other refactors (like #2124 ) so the scope of the refactors remain clear.

@pano9000
Copy link
Contributor

pano9000 commented Feb 2, 2023

a big +1 from my side for that!
I probably would say that #2171 should be done before tackling #2124, as it will be the "easier" task.

I also like the idea of at some point dropping some of the "mistakes" made in earlier version, where we currently need to work with workarounds to maintain backwards compatibility at all costs (but that is a separate topic from this proposal :-))

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

No branches or pull requests

2 participants