Closed niklashaetty closed 8 months ago
Hi @niklashaetty , yes, this looks like a bug. At least according to:
https://fi.wikipedia.org/wiki/Henkil%C3%B6tunnus
it looks like the check character needs to use this table for a lookup value. Can you submit a PR with only the necessary changes to fix the issue?
If not, I can try to get to it this weekend.
Thanks, Brian
@bchavez Yup, i fixed it on a local branch. Not allowed to push it to remote though. Do you have any restrictions in place?
@niklashaetty nice. glad you have a fix. correct, this repo is protected (by default, on GitHub).
to contribute on GitHub:
bchavez/Bogus
to niklashaetty/Bogus
;
niklashaetty/Bogus
issue-392-fix
branchissue-392-fix
branchissue-392-fix
branch to GitHub at niklashaetty/Bogus
niklasheatty/Bogus
on issue-392-fix
to bchavez/Bogus
on master
.and that should do it.
Version Information
What locale are you using with Bogus?
Default, en
What is the expected behavior?
API Extension method Bogus.Person.Henkilötunnus() to return a valid Henkilötunnus.
What is the actual behavior?
I believe the algorithm for calculating the control digit is wrong.
Please provide a stack trace.
N/A
Any possible solutions?
Implement the correct algorithm for the control digit: https://en.wikipedia.org/wiki/National_identification_number#Finland
How do you reproduce the issue?
will generate a control digit of I (upper case i) which is not an allowed character
Do you have a unit test that can demonstrate the bug?
Can you identify the location in Bogus' source code where the problem exists?
Bogus.Extensions.Finland.Henkilötunnus()
zzz is created after the control digit has been set, which is wrong because the control digit depends on the zzz value.
If the bug is confirmed, would you be willing to submit a PR?
Yes, I wrote an implementation i think works above.