-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat(isLicensePlate): adding license plate validators for 'mercosur' and 'pt-BR' locales #1588
feat(isLicensePlate): adding license plate validators for 'mercosur' and 'pt-BR' locales #1588
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1588 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 100 100
Lines 1796 1808 +12
=========================================
+ Hits 1796 1808 +12
Continue to review full report at Codecov.
|
603e854
to
97f9f03
Compare
97f9f03
to
e882576
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good @renanmontebelo
A little suggestion, since we are using country codes for most of the validators including isLicensePlate
. Can you replace mercosur
with corresponding countries ? (Someone validating a license plate in Argentina should expect to use the country code instead of mercosur)
Something like:
const mercosurCountries = ['es-AR', 'es-PY', 'es-UY'];
const mercosur = str =>
/^[A-Z]{2}[ -]?[0-9]{3}[ -]?[A-Z]{2}|[A-Z]{3}[ -]?[0-9][A-Z][0-9]{2}|[A-Z]{4}[ -]?[0-9]{3}|[A-Z]{3}[ -]?[0-9]{4}$/.test(str);
for (let i = 0; i < mercosurCountries.length; i++) {
validators[mercosurCountries[i]] = mercosur;
}
And i guess since Brasil is supporting two types of license plate you can add the mercosur validation to the existing PT-BR
regex.
@profnandaa any feedback on this? Should we add a new mercusor
option?
@tux-tn that's a good point, I was wondering myself if including these rules as So if we're removing mercosur because it's not a valid country locale then I'm OK with keeping only So I pushed a new commit removing mercosur and keeping only pt-br. Thank you for your directions! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@renanmontebelo I also think it will be easier if someone else more familiar with the subject make the changes since the other countries have probably another license plate format before the agreement.
Thank you again for your contribution 🎉 I think the actual version can be merged as it is without issues but let's wait for Anthony and other people feedback about adding mercosur
as a locale.
@renanmontebelo -- I see you already removed |
Update 2021-03-08: removing
mercosur
as per the discussion.Adding 2 new validators for license plates:
pt-BR
: Brazil is in transition from legacy format to Mercosur format, with it's own format rules. This validator accepts both legacy and new formats for Brazil;mercosur
: New rules for Argentina, Brazil, Paraguay, Uruguay and Venezuela (currently suspended from Mercosur but plate format still applies).Checklist