Skip to content

Commit 1394ccc

Browse files
Fix LI regex pattern (#267)
* fix: order of operations * test: improper LI zip is rejected
1 parent f8da65b commit 1394ccc

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/postcode-regexes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const POSTCODE_REGEXES: Map<string, RegExp> = new Map([
8282
[CountryCode.LA, /^\d{5}$/],
8383
[CountryCode.LV, /^(LV-)?\d{4}$/],
8484
[CountryCode.LB, /^(\d{4}([ ]?\d{4})?)?$/],
85-
[CountryCode.LI, /^(948[5-9])|(949[0-7])$/],
85+
[CountryCode.LI, /^(948[5-9]|949[0-7])$/],
8686
[CountryCode.LT, /^(LT-)?\d{5}$/],
8787
[CountryCode.LU, /^(L-)?\d{4}$/],
8888
[CountryCode.MK, /^\d{4}$/],

test/main.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe('postcodeValidator', () => {
2323
{ postcode: '12345', country: 'TW' },
2424
{ postcode: '123456', country: 'TW' },
2525
{ postcode: '12341-12213', country: 'IR' },
26+
{ postcode: '9487', country: 'LI' },
2627
];
2728

2829
expect.assertions(validPostcodes.length);
@@ -49,6 +50,7 @@ describe('postcodeValidator', () => {
4950
{ postcode: '010000', country: 'PE' },
5051
{ postcode: '0A000', country: 'PE' },
5152
{ postcode: '1121234', country: 'IR' },
53+
{ postcode: '9485aaaa', country: 'LI' },
5254
];
5355

5456
expect.assertions(invalidPostcodes.length);

0 commit comments

Comments
 (0)