diff --git a/src/postcode-regexes.ts b/src/postcode-regexes.ts index 2de70ea..0015d10 100644 --- a/src/postcode-regexes.ts +++ b/src/postcode-regexes.ts @@ -171,6 +171,27 @@ export const POSTCODE_REGEXES: Map = new Map([ [CountryCode.WF, /^986\d{2}$/], [CountryCode.XK, /^\d{5}$/], [CountryCode.YT, /^976\d{2}$/], + [CountryCode.GI, /^GX11 1AA/], + [CountryCode.BT, /^\d{5}/], + [CountryCode.AL, /^\d{4}/], + [CountryCode.CU, /^\d{5}/], + [CountryCode.UM, /^96898/], + [CountryCode.AI, /^(?:AI-)?2640/], + [CountryCode.AF, /^\d{4}/], + [CountryCode.SD, /^\d{5}/], + [CountryCode.VC, /^VC\d{4}/], + [CountryCode.TA, /^TDCU 1ZZ/], + [CountryCode.NA, /^\d{5}/], + [CountryCode.EH, /^\d{5}/], + [CountryCode.BL, /^9[78][01]\d{2}/], + [CountryCode.TZ, /^\d{4,5}/], + [CountryCode.AC, /^ASCN 1ZZ/], + [CountryCode.VG, /^VG\d{4}/], + [CountryCode.MZ, /^\d{4}/], + [CountryCode.MF, /^9[78][01]\d{2}/], + [CountryCode.MM, /^\d{5}/], + [CountryCode.SV, /^CP [1-3][1-7][0-2]\d/], + [CountryCode.IR, /^\d{5}-?\d{5}/], [CountryCode.PE, /^[0-2]\d{4}$/], [CountryCode.INTL, /^(?:[A-Z0-9]+([- ]?[A-Z0-9]+)*)?$/i], [CountryCode.CO, /^(0[58]|1[135789]|2[0357]|4[147]|5[024]|6[368]|7[036]|8[1568]|9[4579])\d{4}$/], diff --git a/src/postcode-types.ts b/src/postcode-types.ts index 8e28340..7cc25e4 100644 --- a/src/postcode-types.ts +++ b/src/postcode-types.ts @@ -163,6 +163,27 @@ export enum CountryCode { XK = 'XK', YT = 'YT', PE = 'PE', + GI = "GI", + BT = "BT", + AL = "AL", + CU = "CU", + UM = "UM", + AI = "AI", + AF = "AF", + SD = "SD", + VC = "VC", + TA = "TA", + NA = "NA", + EH = "EH", + BL = "BL", + TZ = "TZ", + AC = "AC", + VG = "VG", + MZ = "MZ", + MF = "MF", + MM = "MM", + SV = "SV", + IR = "IR", INTL = 'INTL', CO = 'CO' } diff --git a/test/main.spec.ts b/test/main.spec.ts index 4dd6e23..2882814 100644 --- a/test/main.spec.ts +++ b/test/main.spec.ts @@ -22,6 +22,7 @@ describe('postcodeValidator', () => { { postcode: '01000', country: 'PE' }, { postcode: '12345', country: 'TW' }, { postcode: '123456', country: 'TW' }, + { postcode: '12341-12213', country: 'IR' }, ]; expect.assertions(validPostcodes.length); @@ -47,6 +48,7 @@ describe('postcodeValidator', () => { { postcode: '0100', country: 'PE' }, { postcode: '010000', country: 'PE' }, { postcode: '0A000', country: 'PE' }, + { postcode: '1121234', country: 'IR' }, ]; expect.assertions(invalidPostcodes.length); @@ -63,12 +65,13 @@ describe('postcodeValidator', () => { describe('postcodeValidatorExistsForCountry', () => { test('should return true for valid country code', () => { - expect.assertions(5); + expect.assertions(6); expect(postcodeValidatorExistsForCountry('PR')).toBeTruthy(); expect(postcodeValidatorExistsForCountry('AU')).toBeTruthy(); expect(postcodeValidatorExistsForCountry('DE')).toBeTruthy(); expect(postcodeValidatorExistsForCountry('KY')).toBeTruthy(); expect(postcodeValidatorExistsForCountry('PE')).toBeTruthy(); + expect(postcodeValidatorExistsForCountry('IR')).toBeTruthy(); }); test('should return false for invalid country code', () => {