Skip to content

Commit

Permalink
Merge pull request #96 from koblas/fix_ean_checksum
Browse files Browse the repository at this point in the history
fix: ean checksum mod10 issue
  • Loading branch information
koblas committed Aug 15, 2023
2 parents 14b6f18 + 9689244 commit d0b55e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/ch/ssn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ describe('ch/ssn', () => {
expect(result.isValid && result.compact).toEqual('7569217076985');
});

test.each(['756.9203.3850.60', '75692170769 85'])('validate:%s', value => {
const result = validate(value);

expect(result.isValid).toEqual(true);
});

it('validate:12345678', () => {
const result = validate('12345678');

Expand Down
2 changes: 1 addition & 1 deletion src/gen/ean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const impl: Validator = {
reverse: true,
});

if (String(10 - sum) !== check) {
if (String((10 - sum) % 10) !== check) {
return { isValid: false, error: new exceptions.InvalidChecksum() };
}

Expand Down

0 comments on commit d0b55e9

Please sign in to comment.