-
-
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
Add Czech license plates #1565
Add Czech license plates #1565
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1565 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 101 101
Lines 1854 1855 +1
=========================================
+ Hits 1854 1855 +1
Continue to review full report at Codecov.
|
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.
Looks good, however, could add a few test cases?
@profnandaa yes, totally agreed, but as I mentioned, I am not really comfortable in writing tests here yet, any guide to get me started? |
This should get you started: test({
validator: 'isLicensePlate',
args: ['cs-CZ'],
valid: [
'valid-plate1',
'valid-plate2'
],
invalid: [
'',
'invalidlicenseplate',
'A1-B2-C3',
'ABC-1-EF',
],
}); Edit and add to |
@@ -1,6 +1,8 @@ | |||
import assertString from './util/assertString'; | |||
|
|||
const validators = { | |||
'cs-CZ': str => | |||
/^(([ABCDEFHKIJKLMNPRSTUVXYZ]|[0-9])-?){5,8}$/.test(str), |
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.
/^(([ABCDEFHKIJKLMNPRSTUVXYZ]|[0-9])-?){5,8}$/.test(str), | |
/^[0-9]([A-Z][0-9]{5}|[A-Z]{2}[0-9]{4})$/.test(str), |
nit: we can increase accuracy in this way.
Passing examples:
0A18929
0AB1892
This regex does not take into account custom license plates and we have to check it separately.
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.
This shortened version looks way better, I agree @fedeci, but this does not include disallowed characters, which include O, G, Q, and W.
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.
According to what I understood from wikipedia, those characters are only disallowed in custom license plates🤔
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.
I think maybe there is conflicting information on the article in English, and the one which is in Czech, this is a paragraph translated from the Czech one:
Today's marks contain five to seven characters, depending on the vehicle type (numbers and letters without accents, except for G, O, Q, W, which could be confused with C, V, and the number 0 or the number 6).
This means, that this applies to all license plates, not just custom ones.
@profnandaa looks stale , lets get it merged if author is still available or I could add in few tests with the new PR |
Yes please add more tests as said by @profnandaa so we could merge it. This is to limit stale PRs |
@rubiin added those tests! |
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.
Thanks for your contribution! 🎉
I have added Czech license plates with regards to all the possible cases I found. RegExr with tests
Checklist