-
Notifications
You must be signed in to change notification settings - Fork 32
fix: mod11 bug with dk/cvr #136
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -64,7 +64,7 @@ const impl: Validator = { | |||||
| modulus: 11, | ||||||
| weights: [2, 7, 6, 5, 4, 3, 2, 1], | ||||||
| }); | ||||||
| if (String((11 - sum) % 10) !== check) { | ||||||
| if (String((11 - (sum % 11)) % 11) !== check) { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The updated checksum logic is correct. However, it can be slightly simplified. The
Suggested change
|
||||||
| return { isValid: false, error: new exceptions.InvalidChecksum() }; | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
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.
The new test cases are great for verifying the fix. To make them more robust, you could also assert the
compactform of the number, similar to the test on line 11. This would ensure that the cleaning logic works correctly for these inputs in addition to the validation logic.