-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathpostcode-regexes.ts
198 lines (197 loc) · 7.06 KB
/
postcode-regexes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import { CountryCode } from './postcode-types';
// TODO: Remove CountryCode.UK in next major version release
export const POSTCODE_REGEXES: Map<string, RegExp> = new Map([
[
CountryCode.UK,
/^([A-Z]){1}([0-9][0-9]|[0-9]|[A-Z][0-9][A-Z]|[A-Z][0-9][0-9]|[A-Z][0-9]|[0-9][A-Z]){1}([ ])?([0-9][A-z][A-z]){1}$/i,
],
[
CountryCode.GB,
/^([A-Z]){1}([0-9][0-9]|[0-9]|[A-Z][0-9][A-Z]|[A-Z][0-9][0-9]|[A-Z][0-9]|[0-9][A-Z]){1}([ ])?([0-9][A-z][A-z]){1}$/i,
],
[CountryCode.JE, /^JE\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}$/],
[CountryCode.GG, /^GY\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}$/],
[CountryCode.IM, /^IM\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}$/],
[CountryCode.US, /^([0-9]{5})(?:-([0-9]{4}))?$/],
[CountryCode.CA, /^([ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ])\s*([0-9][ABCEGHJKLMNPRSTVWXYZ][0-9])$/i],
[CountryCode.IE, /^([AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}$/],
[CountryCode.DE, /^\d{5}$/],
[CountryCode.JP, /^\d{3}-\d{4}$/],
[CountryCode.FR, /^\d{2}[ ]?\d{3}$/],
[CountryCode.AU, /^\d{4}$/],
[CountryCode.IT, /^\d{5}$/],
[CountryCode.CH, /^\d{4}$/],
[CountryCode.AT, /^(?!0)\d{4}$/],
[CountryCode.ES, /^(?:0[1-9]|[1-4]\d|5[0-2])\d{3}$/],
[CountryCode.NL, /^\d{4}[ ]?[A-Z]{2}$/],
[CountryCode.BE, /^\d{4}$/],
[CountryCode.DK, /^\d{4}$/],
[CountryCode.SE, /^(SE-)?\d{3}[ ]?\d{2}$/],
[CountryCode.NO, /^\d{4}$/],
[CountryCode.BR, /^\d{5}[\-]?\d{3}$/],
[CountryCode.PT, /^\d{4}([\-]\d{3})?$/],
[CountryCode.FI, /^(FI-|AX-)?\d{5}$/],
[CountryCode.AX, /^22\d{3}$/],
[CountryCode.KR, /^\d{5}$/],
[CountryCode.CN, /^\d{6}$/],
[CountryCode.TW, /^\d{3}(\d{2,3})?$/],
[CountryCode.SG, /^\d{6}$/],
[CountryCode.DZ, /^\d{5}$/],
[CountryCode.AD, /^AD\d{3}$/],
[CountryCode.AR, /^([A-HJ-NP-Z])?\d{4}([A-Z]{3})?$/],
[CountryCode.AM, /^(37)?\d{4}$/],
[CountryCode.AZ, /^\d{4}$/],
[CountryCode.BH, /^((1[0-2]|[2-9])\d{2})?$/],
[CountryCode.BD, /^\d{4}$/],
[CountryCode.BB, /^(BB\d{5})?$/],
[CountryCode.BY, /^\d{6}$/],
[CountryCode.BM, /^[A-Z]{2}[ ]?[A-Z0-9]{2}$/],
[CountryCode.BA, /^\d{5}$/],
[CountryCode.IO, /^BBND 1ZZ$/],
[CountryCode.BN, /^[A-Z]{2}[ ]?\d{4}$/],
[CountryCode.BG, /^\d{4}$/],
[CountryCode.KH, /^\d{5}$/],
[CountryCode.CV, /^\d{4}$/],
[CountryCode.CL, /^\d{7}$/],
[CountryCode.CR, /^(\d{4,5}|\d{3}-\d{4})$/],
[CountryCode.HR, /^(HR-)?\d{5}$/],
[CountryCode.CY, /^\d{4}$/],
[CountryCode.CZ, /^\d{3}[ ]?\d{2}$/],
[CountryCode.DO, /^\d{5}$/],
[CountryCode.EC, /^([A-Z]\d{4}[A-Z]|(?:[A-Z]{2})?\d{6})?$/],
[CountryCode.EG, /^\d{5}$/],
[CountryCode.EE, /^\d{5}$/],
[CountryCode.FO, /^\d{3}$/],
[CountryCode.GE, /^\d{4}$/],
[CountryCode.GR, /^\d{3}[ ]?\d{2}$/],
[CountryCode.GL, /^39\d{2}$/],
[CountryCode.GT, /^\d{5}$/],
[CountryCode.HT, /^\d{4}$/],
[CountryCode.HN, /^(?:\d{5})?$/],
[CountryCode.HU, /^\d{4}$/],
[CountryCode.IS, /^\d{3}$/],
[CountryCode.IN, /^\d{6}$/],
[CountryCode.ID, /^\d{5}$/],
[CountryCode.IL, /^\d{5,7}$/],
[CountryCode.JO, /^\d{5}$/],
[CountryCode.KZ, /^\d{6}$/],
[CountryCode.KE, /^\d{5}$/],
[CountryCode.KW, /^\d{5}$/],
[CountryCode.KY, /^KY[123]-\d{4}$/],
[CountryCode.LA, /^\d{5}$/],
[CountryCode.LV, /^(LV-)?\d{4}$/],
[CountryCode.LB, /^(\d{4}([ ]?\d{4})?)?$/],
[CountryCode.LI, /^(948[5-9])|(949[0-7])$/],
[CountryCode.LT, /^(LT-)?\d{5}$/],
[CountryCode.LU, /^(L-)?\d{4}$/],
[CountryCode.MK, /^\d{4}$/],
[CountryCode.MY, /^\d{5}$/],
[CountryCode.MV, /^\d{5}$/],
[CountryCode.MT, /^[A-Z]{3}[ ]?\d{2,4}$/],
[CountryCode.MU, /^((\d|[A-Z])\d{4})?$/],
[CountryCode.MX, /^\d{5}$/],
[CountryCode.MD, /^\d{4}$/],
[CountryCode.MC, /^980\d{2}$/],
[CountryCode.MA, /^\d{5}$/],
[CountryCode.NP, /^\d{5}$/],
[CountryCode.NZ, /^\d{4}$/],
[CountryCode.NI, /^((\d{4}-)?\d{3}-\d{3}(-\d{1})?)?$/],
[CountryCode.NG, /^(\d{6})?$/],
[CountryCode.OM, /^(PC )?\d{3}$/],
[CountryCode.PA, /^\d{4}$/],
[CountryCode.PK, /^\d{5}$/],
[CountryCode.PY, /^\d{4}$/],
[CountryCode.PH, /^\d{4}$/],
[CountryCode.PL, /^\d{2}-\d{3}$/],
[CountryCode.PR, /^00[679]\d{2}([ \-]\d{4})?$/],
[CountryCode.RO, /^\d{6}$/],
[CountryCode.RU, /^\d{6}$/],
[CountryCode.SM, /^4789\d$/],
[CountryCode.SA, /^\d{5}$/],
[CountryCode.SN, /^\d{5}$/],
[CountryCode.SK, /^\d{3}[ ]?\d{2}$/],
[CountryCode.SI, /^(SI-)?\d{4}$/],
[CountryCode.ZA, /^\d{4}$/],
[CountryCode.LK, /^\d{5}$/],
[CountryCode.TJ, /^\d{6}$/],
[CountryCode.TH, /^\d{5}$/],
[CountryCode.TN, /^\d{4}$/],
[CountryCode.TR, /^\d{5}$/],
[CountryCode.TM, /^\d{6}$/],
[CountryCode.UA, /^\d{5}$/],
[CountryCode.UY, /^\d{5}$/],
[CountryCode.UZ, /^\d{6}$/],
[CountryCode.VA, /^00120$/],
[CountryCode.VE, /^\d{4}$/],
[CountryCode.ZM, /^\d{5}$/],
[CountryCode.AS, /^96799$/],
[CountryCode.CC, /^6799$/],
[CountryCode.CK, /^\d{4}$/],
[CountryCode.RS, /^\d{5,6}$/],
[CountryCode.ME, /^8\d{4}$/],
[CountryCode.CS, /^\d{5}$/],
[CountryCode.YU, /^\d{5}$/],
[CountryCode.CX, /^6798$/],
[CountryCode.ET, /^\d{4}$/],
[CountryCode.FK, /^FIQQ 1ZZ$/],
[CountryCode.NF, /^2899$/],
[CountryCode.FM, /^(9694[1-4])([ \-]\d{4})?$/],
[CountryCode.GF, /^9[78]3\d{2}$/],
[CountryCode.GN, /^\d{3}$/],
[CountryCode.GP, /^9[78][01]\d{2}$/],
[CountryCode.GS, /^SIQQ 1ZZ$/],
[CountryCode.GU, /^969[123]\d([ \-]\d{4})?$/],
[CountryCode.GW, /^\d{4}$/],
[CountryCode.HM, /^\d{4}$/],
[CountryCode.IQ, /^\d{5}$/],
[CountryCode.KG, /^\d{6}$/],
[CountryCode.LR, /^\d{4}$/],
[CountryCode.LS, /^\d{3}$/],
[CountryCode.MG, /^\d{3}$/],
[CountryCode.MH, /^969[67]\d([ \-]\d{4})?$/],
[CountryCode.MN, /^\d{5}$/],
[CountryCode.MP, /^9695[012]([ \-]\d{4})?$/],
[CountryCode.MQ, /^9[78]2\d{2}$/],
[CountryCode.NC, /^988\d{2}$/],
[CountryCode.NE, /^\d{4}$/],
[CountryCode.VI, /^008(([0-4]\d)|(5[01]))([ \-]\d{4})?$/],
[CountryCode.VN, /^\d{6}$/],
[CountryCode.PF, /^987\d{2}$/],
[CountryCode.PG, /^\d{3}$/],
[CountryCode.PM, /^9[78]5\d{2}$/],
[CountryCode.PN, /^PCRN 1ZZ$/],
[CountryCode.PW, /^96940$/],
[CountryCode.RE, /^9[78]4\d{2}$/],
[CountryCode.SH, /^(ASCN|STHL) 1ZZ$/],
[CountryCode.SJ, /^\d{4}$/],
[CountryCode.SO, /^\d{5}$/],
[CountryCode.SZ, /^[HLMS]\d{3}$/],
[CountryCode.TC, /^TKCA 1ZZ$/],
[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}$/],
]);