-
Notifications
You must be signed in to change notification settings - Fork 295
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
fixing civil id validation for those ids starting with 300 #195
Conversation
Can you add test for an ID number that fails without this fix? This helps to ensure that this fix will continue to work with future changes. Thanks. |
@burhan Sorry for the delay here. github doesn't give notifications when you add commits to a pull request. You have to actually make a comment for notifications to be sent. |
I just looked over your latest version and I think it needs to be re-worked a bit. The problem is that a valid date based civil id number will never go through the date validation logic because it will always have a valid checksum which ends the validation. You can see this by looking at the code coverage after running the tests. The last line of the From a high level, the validation logic could work something like this:
This pull request also needs a couple of housekeeping items:
Thanks for your contribution. I'm looking forward to reviewing your updated pull request. |
After some testing around, I managed to solve the issue by adding a century prefix to the dates (since they are still valid) - this way, it ensures that 300xxx ids are validated correctly. Updated the test cases as well. I think think should fix it; pending any travis blockers. |
1acbaa3
to
7c43304
Compare
Nice solution. There are some issues with missing tests and an unnecessary duplicated regex but it's not related to addressing the validation bug for IDs starting with 3. If you want to work on fixing up these other issues, you can tackle that in a new PR. The only thing left for you do is to rebase and squash your commits into 1 commit. Thanks. |
HI @benkonrath - can you explain a bit more on the duplicated regex? I would like to close it up here. Also the tests were updated to check 3xx civil ids. Appreciate if you could clarify on this. |
Sure. It's not necessary to have the first regex check because
Since there is only 1 regex, you can inherit from the It would also be nice to have tests for these cases:
Thanks for looking into this. |
7c43304
to
e7ff8e1
Compare
@benkonrath I'll raise another PR so it inherits from |
Thanks. Merged via 7c26f09. |
Kuwait has issued ids starting with 300x that are valid; and these fail the birthdate check; this check and been given lower priority over the checksum validation.