Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/bg/vat.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,18 @@ describe('bg/vat', () => {

expect(result.error).toBeInstanceOf(InvalidChecksum);
});

// A registered VAT number starting with 8. The first digit is not
// restricted: python-stdnum's bg/vat has no such rule.
it('validate:BG 831642181', () => {
const result = validate('BG 831642181');

expect(result.isValid && result.compact).toEqual('831642181');
});

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

expect(result.error).toBeInstanceOf(InvalidChecksum);
});
});
4 changes: 0 additions & 4 deletions src/bg/vat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ const impl: Validator = {
return { isValid: false, error: new exceptions.InvalidFormat() };
}

if (!['0', '1', '2', '3', '9'].includes(value[0])) {
return { isValid: false, error: new exceptions.InvalidFormat() };
}

if (value.length === 9) {
if (!checkLegal(value)) {
return { isValid: false, error: new exceptions.InvalidChecksum() };
Expand Down