validates_zipcode 0.3.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,14 +5,27 @@ module ValidatesZipcode
5
5
 
6
6
  ZIPCODES_TRANSFORMATIONS = {
7
7
  AT: ->(z) { z.scan(/\d/).join },
8
+ ES: :AT,
8
9
  CA: ->(z) { z.upcase.scan(WORD_CHAR_AND_DIGIT).insert(3, ' ').join },
9
10
  CZ: ->(z) { z.scan(/\d/).insert(3, ' ').join },
10
- DE: ->(z) { z.scan(/\d/).join.rjust(5, '0') },
11
+ DE: ->(z) {
12
+ digits = z.scan(/\d/)
13
+ result = digits.join
14
+ result.prepend('0') if digits.count < 5
15
+ result
16
+ },
11
17
  GB: ->(z) { z.upcase.scan(WORD_CHAR_AND_DIGIT).insert(-4, ' ').join },
12
18
  NL: ->(z) { z.upcase.scan(WORD_CHAR_AND_DIGIT).insert(4, ' ').join },
13
19
  PL: ->(z) { z.scan(/\d/).insert(2, '-').join },
14
20
  SK: :CZ,
15
21
  UK: :GB,
22
+ MT: :GB,
23
+ FK: :GB,
24
+ GS: :GB,
25
+ PN: :GB,
26
+ SH: :GB,
27
+ TC: :GB,
28
+ GI: :GB,
16
29
  US: ->(z) {
17
30
  digits = z.scan(/\d/)
18
31
  digits.insert(5, '-') if digits.count > 5
@@ -21,6 +21,7 @@ module ValidatesZipcode
21
21
  @country_code = options.fetch(:country_code, nil)
22
22
  @country_code_attribute = options.fetch(:country_code_attribute, :country_alpha2)
23
23
  @excluded_country_codes = options.fetch(:excluded_country_codes, [])
24
+ @format = options.fetch(:format, false)
24
25
  @message = options.fetch(:message, nil)
25
26
  super
26
27
  end
@@ -29,12 +30,13 @@ module ValidatesZipcode
29
30
  alpha2 = @country_code || record.send(@country_code_attribute)
30
31
  options = { zipcode: value.to_s,
31
32
  country_alpha2: alpha2,
32
- excluded_country_codes: @excluded_country_codes }
33
+ excluded_country_codes: @excluded_country_codes,
34
+ format: @format }
33
35
 
34
- unless ValidatesZipcode::Zipcode.new(options).valid?
35
- message = @message || I18n.t('errors.messages.invalid_zipcode', value: value, default: 'Zipcode is invalid')
36
- record.errors.add(attribute, :invalid_zipcode, message: message)
37
- end
36
+ return if ValidatesZipcode::Zipcode.new(options).valid?
37
+
38
+ message = @message || I18n.t('errors.messages.invalid_zipcode', value: value, default: 'Zipcode is invalid')
39
+ record.errors.add(attribute, :invalid_zipcode, message: message)
38
40
  end
39
41
  end
40
42
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ValidatesZipcode
3
- VERSION = '0.3.3'
3
+ VERSION = '0.5.0'
4
4
  end
@@ -7,18 +7,22 @@ module ValidatesZipcode
7
7
  @zipcode = args.fetch(:zipcode)
8
8
  @country_alpha2 = args.fetch(:country_alpha2)
9
9
  @excluded_country_codes = args.fetch(:excluded_country_codes, [])
10
+ @format = args.fetch(:format, false)
10
11
  end
11
12
 
12
13
  def valid?
13
14
  return true if @excluded_country_codes.include?(@country_alpha2)
14
15
  return true unless regexp
15
- !!(regexp =~ @zipcode)
16
+
17
+ zipcode = @format ? formatted_zip : @zipcode
18
+ !!(regexp =~ zipcode)
16
19
  end
17
20
  alias_method :validate, :valid?
18
21
 
19
22
  def format
20
- raise InvalidZipcodeError, "invalid zipcode #{@zipcode} for country #{@country_alpha2.to_s.upcase}" unless valid?
21
- Formatter.new(zipcode: @zipcode, country_alpha2: @country_alpha2).format
23
+ raise InvalidZipcodeError, "invalid zipcode #{formatted_zip} for country #{@country_alpha2.to_s.upcase}" unless valid?
24
+
25
+ formatted_zip
22
26
  end
23
27
 
24
28
  private
@@ -26,5 +30,9 @@ module ValidatesZipcode
26
30
  def regexp
27
31
  @regexp ||= regexp_for_country_alpha2(@country_alpha2)
28
32
  end
33
+
34
+ def formatted_zip
35
+ @formatted_zip ||= Formatter.new(zipcode: @zipcode, country_alpha2: @country_alpha2).format
36
+ end
29
37
  end
30
38
  end
@@ -39,4 +39,4 @@ describe ValidatesZipcode::Formatter, '#format' do
39
39
  from_zip, to_zip = formatting.first
40
40
  expect(::ValidatesZipcode::Formatter.new(zipcode: from_zip, country_alpha2: country).format).to eq(to_zip)
41
41
  end
42
- end
42
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,3568 @@
1
1
  # frozen_string_literal: true
2
2
  require 'validates_zipcode'
3
+
4
+ TEST_DATA = {
5
+ GB: {
6
+ valid: [
7
+ 'ID1 1QD',
8
+ 'M32 0JG',
9
+ 'NE30 1DP',
10
+ 'OX49 5NU',
11
+ 'SW1A 2AA',
12
+ 'W1K 7DA',
13
+ 'id1 1qd',
14
+ 'Sw1A 2aA',
15
+ 'id11qd',
16
+ 'SW1A2AA'
17
+ ],
18
+ invalid: [
19
+ nil,
20
+ '',
21
+ 'invalid_zip',
22
+ 'nope',
23
+ 'id11qd1000',
24
+ '28001'
25
+ ]
26
+ },
27
+ UK: {
28
+ valid: [
29
+ 'ID1 1QD',
30
+ 'M32 0JG',
31
+ 'NE30 1DP',
32
+ 'OX49 5NU',
33
+ 'SW1A 2AA',
34
+ 'W1K 7DA',
35
+ 'id1 1qd',
36
+ 'Sw1A 2aA',
37
+ 'id11qd',
38
+ 'SW1A2AA'
39
+ ],
40
+ invalid: [
41
+ nil,
42
+ '',
43
+ 'invalid_zip',
44
+ 'nope',
45
+ 'id11qd1000',
46
+ '28001'
47
+ ]
48
+ },
49
+ JE: {
50
+ valid: [
51
+ 'JE1 1QD',
52
+ 'JE32 0JG',
53
+ 'JE30 1DP',
54
+ 'JE49 5NU',
55
+ 'je1 2aA'
56
+ ],
57
+ invalid: [
58
+ nil,
59
+ '',
60
+ 'invalid_zip',
61
+ 'nope',
62
+ 'id11qd1000',
63
+ '28001'
64
+ ]
65
+ },
66
+ GG: {
67
+ valid: [
68
+ 'GY1 1QD',
69
+ 'GY32 0JG',
70
+ 'GY30 1DP',
71
+ 'GY49 5NU',
72
+ 'gy1 2aA'
73
+ ],
74
+ invalid: [
75
+ nil,
76
+ '',
77
+ 'invalid_zip',
78
+ 'nope',
79
+ 'id11qd1000',
80
+ '28001'
81
+ ]
82
+ },
83
+ IM: {
84
+ valid: [
85
+ 'IM1 1QD',
86
+ 'IM32 0JG',
87
+ 'IM30 1DP',
88
+ 'IM49 5NU',
89
+ 'im1 2aA'
90
+ ],
91
+ invalid: [
92
+ nil,
93
+ '',
94
+ 'invalid_zip',
95
+ 'nope',
96
+ 'id11qd1000',
97
+ '28001'
98
+ ]
99
+ },
100
+ US: {
101
+ valid: [
102
+ 12_345,
103
+ '12345',
104
+ '12345-1234',
105
+ '12345-123456',
106
+ '12345 1234',
107
+ '12345 123456'
108
+ ],
109
+ invalid: [
110
+ nil,
111
+ '',
112
+ 'invalid_zip',
113
+ '1234',
114
+ '12345-12345',
115
+ 'D0D0D0'
116
+ ]
117
+ },
118
+ IE: {
119
+ valid: [
120
+ 'D02 AF30',
121
+ 'X91 PK81',
122
+ 'V94 H2PP',
123
+ 'D07 R6YE',
124
+ 'D6W1234',
125
+ 'A230984',
126
+ 'D00AV92',
127
+ 'Y631FHK',
128
+ 'A000000',
129
+ 'D44N4X4'
130
+ ],
131
+ invalid: [
132
+ nil,
133
+ '',
134
+ 'invalid_zip',
135
+ '1234',
136
+ '12345-12345'
137
+ ]
138
+ },
139
+ CA: {
140
+ valid: [
141
+ 'A1J2Z9',
142
+ 'P5R3E3',
143
+ 'S9G 6S0',
144
+ 'V8G3K9'
145
+ ],
146
+ invalid: [
147
+ nil,
148
+ '',
149
+ 'invalid_zip',
150
+ 'C1424CHN',
151
+ '12345',
152
+ 'D0D0D0'
153
+ ]
154
+ },
155
+ DE: {
156
+ valid: %w[
157
+ 07113
158
+ 02566
159
+ 66261
160
+ ],
161
+ invalid: [
162
+ nil,
163
+ '',
164
+ 'invalid_zip',
165
+ '1234',
166
+ '12345-12345',
167
+ 'D0D0D0'
168
+ ]
169
+ },
170
+ AU: {
171
+ valid: %w[
172
+ 7113
173
+ 2566
174
+ 6261
175
+ 7113
176
+ ],
177
+ invalid: [
178
+ nil,
179
+ '',
180
+ 'invalid_zip',
181
+ '12345',
182
+ '1234-1234',
183
+ 'D0D0D0'
184
+ ]
185
+ },
186
+ IT: {
187
+ valid: %w[
188
+ 07113
189
+ 02566
190
+ 66261
191
+ ],
192
+ invalid: [
193
+ nil,
194
+ '',
195
+ 'invalid_zip',
196
+ '1234',
197
+ '12345-12345',
198
+ 'D0D0D0'
199
+ ]
200
+ },
201
+ CH: {
202
+ valid: %w[
203
+ 7113
204
+ 2566
205
+ 6261
206
+ 7113
207
+ ],
208
+ invalid: [
209
+ nil,
210
+ '',
211
+ 'invalid_zip',
212
+ '12345',
213
+ '1234-1234',
214
+ 'D0D0D0'
215
+ ]
216
+ },
217
+ AT: {
218
+ valid: %w[
219
+ 7113
220
+ 2566
221
+ 6261
222
+ 7113
223
+ ],
224
+ invalid: [
225
+ nil,
226
+ '',
227
+ 'invalid_zip',
228
+ '12345',
229
+ '1234-1234',
230
+ 'D0D0D0'
231
+ ]
232
+ },
233
+ ES: {
234
+ valid: %w[
235
+ 07113
236
+ 02566
237
+ 66261
238
+ ],
239
+ invalid: [
240
+ nil,
241
+ '',
242
+ 'invalid_zip',
243
+ '1234',
244
+ '12345-12345',
245
+ 'D0D0D0'
246
+ ]
247
+ },
248
+ NL: {
249
+ valid: [
250
+ '1001 AA',
251
+ '6388SW',
252
+ '7144SX',
253
+ '1001 AA'
254
+ ],
255
+ invalid: [
256
+ nil,
257
+ '',
258
+ 'invalid_zip',
259
+ '0100 AA',
260
+ '1001 SS',
261
+ '1111 SD',
262
+ '1001 SA',
263
+ '1001 aa',
264
+ '6388sW'
265
+ ]
266
+ },
267
+ BE: {
268
+ valid: %w[
269
+ 7113
270
+ 2566
271
+ 6261
272
+ 7113
273
+ ],
274
+ invalid: [
275
+ nil,
276
+ '',
277
+ 'invalid_zip',
278
+ '12345',
279
+ '1234-1234',
280
+ 'D0D0D0'
281
+ ]
282
+ },
283
+ DK: {
284
+ valid: %w[
285
+ 7113
286
+ 2566
287
+ 6261
288
+ 7113
289
+ ],
290
+ invalid: [
291
+ nil,
292
+ '',
293
+ 'invalid_zip',
294
+ '12345',
295
+ '1234-1234',
296
+ 'D0D0D0'
297
+ ]
298
+ },
299
+ NO: {
300
+ valid: %w[
301
+ 7113
302
+ 2566
303
+ 6261
304
+ 7113
305
+ ],
306
+ invalid: [
307
+ nil,
308
+ '',
309
+ 'invalid_zip',
310
+ '12345',
311
+ '1234-1234',
312
+ 'D0D0D0'
313
+ ]
314
+ },
315
+ FI: {
316
+ valid: %w[
317
+ 07113
318
+ 02566
319
+ 66261
320
+ ],
321
+ invalid: [
322
+ nil,
323
+ '',
324
+ 'invalid_zip',
325
+ '1234',
326
+ '12345-12345',
327
+ 'D0D0D0'
328
+ ]
329
+ },
330
+ AX: {
331
+ valid: %w[
332
+ 22113
333
+ 22566
334
+ 22261
335
+ ],
336
+ invalid: [
337
+ nil,
338
+ '',
339
+ 'invalid_zip',
340
+ '07113',
341
+ '2234',
342
+ '22113-22113',
343
+ 'D0D0D0'
344
+ ]
345
+ },
346
+ KR: {
347
+ valid: [
348
+ '72315',
349
+ '723-150',
350
+ '11011',
351
+ '110-110'
352
+ ],
353
+ invalid: [
354
+ nil,
355
+ '',
356
+ 'invalid_zip',
357
+ '723155'
358
+ ]
359
+ },
360
+ CN: {
361
+ valid: %w[
362
+ 071134
363
+ 025663
364
+ 662612
365
+ 071135
366
+ ],
367
+ invalid: [
368
+ nil,
369
+ '',
370
+ 'invalid_zip',
371
+ '12345',
372
+ '123456-123456',
373
+ 'D0D0D0'
374
+ ]
375
+ },
376
+ SG: {
377
+ valid: %w[
378
+ 071134
379
+ 025663
380
+ 662612
381
+ 071135
382
+ ],
383
+ invalid: [
384
+ nil,
385
+ '',
386
+ 'invalid_zip',
387
+ '12345',
388
+ '123456-123456',
389
+ 'D0D0D0'
390
+ ]
391
+ },
392
+ DZ: {
393
+ valid: %w[
394
+ 07113
395
+ 02566
396
+ 66261
397
+ ],
398
+ invalid: [
399
+ nil,
400
+ '',
401
+ 'invalid_zip',
402
+ '1234',
403
+ '12345-12345',
404
+ 'D0D0D0'
405
+ ]
406
+ },
407
+ AD: {
408
+ valid: %w[
409
+ AD113
410
+ AD566
411
+ AD261
412
+ ],
413
+ invalid: [
414
+ nil,
415
+ '',
416
+ 'invalid_zip',
417
+ 'AD34',
418
+ 'AD113-AD113',
419
+ 'D0D0D0'
420
+ ]
421
+ },
422
+ AR: {
423
+ valid: %w[
424
+ C1234CHN
425
+ C1234
426
+ ],
427
+ invalid: [
428
+ nil,
429
+ '',
430
+ 'invalid_zip',
431
+ 'I1234'
432
+ ]
433
+ },
434
+ AM: {
435
+ valid: %w[
436
+ 375010
437
+ 0010
438
+ 1234
439
+ ],
440
+ invalid: [
441
+ nil,
442
+ '',
443
+ 'invalid_zip',
444
+ '123456'
445
+ ]
446
+ },
447
+ BD: {
448
+ valid: %w[
449
+ 7113
450
+ 2566
451
+ 6261
452
+ 7113
453
+ ],
454
+ invalid: [
455
+ nil,
456
+ '',
457
+ 'invalid_zip',
458
+ '12345',
459
+ '1234-1234',
460
+ 'D0D0D0'
461
+ ]
462
+ },
463
+ BB: {
464
+ valid: %w[
465
+ BB12345
466
+ BB20000
467
+ BB15156667
468
+ ],
469
+ invalid: [
470
+ nil,
471
+ '',
472
+ 'invalid_zip',
473
+ 'XY12345',
474
+ 'BB54837'
475
+ ]
476
+ },
477
+ BY: {
478
+ valid: %w[
479
+ 071134
480
+ 025663
481
+ 662612
482
+ 071135
483
+ ],
484
+ invalid: [
485
+ nil,
486
+ '',
487
+ 'invalid_zip',
488
+ '12345',
489
+ '123456-123456',
490
+ 'D0D0D0'
491
+ ]
492
+ },
493
+ BM: {
494
+ valid: [
495
+ 'ABCD',
496
+ 'AB12',
497
+ 'AB CD',
498
+ 'AB 12'
499
+ ],
500
+ invalid: [
501
+ nil,
502
+ '',
503
+ 'invalid_zip',
504
+ 'ABC 12',
505
+ '1234',
506
+ '12 34'
507
+ ]
508
+ },
509
+ BA: {
510
+ valid: %w[
511
+ 07113
512
+ 02566
513
+ 66261
514
+ ],
515
+ invalid: [
516
+ nil,
517
+ '',
518
+ 'invalid_zip',
519
+ '1234',
520
+ '12345-12345',
521
+ 'D0D0D0'
522
+ ]
523
+ },
524
+ BN: {
525
+ valid: [
526
+ 'BC1234',
527
+ 'KX 1234',
528
+ 'TC1234'
529
+ ],
530
+ invalid: [
531
+ nil,
532
+ '',
533
+ 'invalid_zip',
534
+ 'XC1234',
535
+ 'XC 1234'
536
+ ]
537
+ },
538
+ BG: {
539
+ valid: %w[
540
+ 7113
541
+ 2566
542
+ 6261
543
+ 7113
544
+ ],
545
+ invalid: [
546
+ nil,
547
+ '',
548
+ 'invalid_zip',
549
+ '12345',
550
+ '1234-1234',
551
+ 'D0D0D0'
552
+ ]
553
+ },
554
+ KH: {
555
+ valid: %w[
556
+ 07113
557
+ 02566
558
+ 66261
559
+ ],
560
+ invalid: [
561
+ nil,
562
+ '',
563
+ 'invalid_zip',
564
+ '1234',
565
+ '12345-12345',
566
+ 'D0D0D0'
567
+ ]
568
+ },
569
+ CV: {
570
+ valid: %w[
571
+ 7113
572
+ 2566
573
+ 6261
574
+ 7113
575
+ ],
576
+ invalid: [
577
+ nil,
578
+ '',
579
+ 'invalid_zip',
580
+ '12345',
581
+ '1234-1234',
582
+ 'D0D0D0'
583
+ ]
584
+ },
585
+ CL: {
586
+ valid: [
587
+ '123-1233',
588
+ '000-0000',
589
+ '1234567'
590
+ ],
591
+ invalid: [
592
+ nil,
593
+ '',
594
+ 'invalid_zip',
595
+ '1234',
596
+ '12345',
597
+ 'C1424CHN',
598
+ '122-12345'
599
+ ]
600
+ },
601
+ HR: {
602
+ valid: %w[
603
+ 07113
604
+ 02566
605
+ 66261
606
+ ],
607
+ invalid: [
608
+ nil,
609
+ '',
610
+ 'invalid_zip',
611
+ '1234',
612
+ '12345-12345',
613
+ 'D0D0D0'
614
+ ]
615
+ },
616
+ CY: {
617
+ valid: %w[
618
+ 7113
619
+ 2566
620
+ 6261
621
+ 7113
622
+ ],
623
+ invalid: [
624
+ nil,
625
+ '',
626
+ 'invalid_zip',
627
+ '12345',
628
+ '1234-1234',
629
+ 'D0D0D0'
630
+ ]
631
+ },
632
+ CZ: {
633
+ valid: [
634
+ '12000',
635
+ '721 00'
636
+ ],
637
+ invalid: [
638
+ nil,
639
+ '',
640
+ 'invalid_zip',
641
+ '981 32'
642
+ ]
643
+ },
644
+ DO: {
645
+ valid: %w[
646
+ 07113
647
+ 02566
648
+ 66261
649
+ ],
650
+ invalid: [
651
+ nil,
652
+ '',
653
+ 'invalid_zip',
654
+ '1234',
655
+ '12345-12345',
656
+ 'D0D0D0'
657
+ ]
658
+ },
659
+ EC: {
660
+ valid: %w[
661
+ 071134
662
+ 025663
663
+ 662612
664
+ 071135
665
+ ],
666
+ invalid: [
667
+ nil,
668
+ '',
669
+ 'invalid_zip',
670
+ '12345',
671
+ '123456-123456',
672
+ 'D0D0D0'
673
+ ]
674
+ },
675
+ EE: {
676
+ valid: %w[
677
+ 07113
678
+ 02566
679
+ 66261
680
+ ],
681
+ invalid: [
682
+ nil,
683
+ '',
684
+ 'invalid_zip',
685
+ '1234',
686
+ '12345-12345',
687
+ 'D0D0D0'
688
+ ]
689
+ },
690
+ FO: {
691
+ valid: %w[
692
+ 711
693
+ 256
694
+ 626
695
+ 711
696
+ ],
697
+ invalid: [
698
+ nil,
699
+ '',
700
+ 'invalid_zip',
701
+ '1234',
702
+ '123-123',
703
+ 'D0D0D0'
704
+ ]
705
+ },
706
+ GE: {
707
+ valid: %w[
708
+ 7113
709
+ 2566
710
+ 6261
711
+ 7113
712
+ ],
713
+ invalid: [
714
+ nil,
715
+ '',
716
+ 'invalid_zip',
717
+ '12345',
718
+ '1234-1234',
719
+ 'D0D0D0'
720
+ ]
721
+ },
722
+ GL: {
723
+ valid: %w[
724
+ 3900
725
+ 3973
726
+ ],
727
+ invalid: [
728
+ nil,
729
+ '',
730
+ 'invalid_zip',
731
+ '1234'
732
+ ]
733
+ },
734
+ GT: {
735
+ valid: %w[
736
+ 07113
737
+ 02566
738
+ 66261
739
+ ],
740
+ invalid: [
741
+ nil,
742
+ '',
743
+ 'invalid_zip',
744
+ '1234',
745
+ '12345-12345',
746
+ 'D0D0D0'
747
+ ]
748
+ },
749
+ HT: {
750
+ valid: %w[
751
+ 7113
752
+ 2566
753
+ 6261
754
+ 7113
755
+ ],
756
+ invalid: [
757
+ nil,
758
+ '',
759
+ 'invalid_zip',
760
+ '12345',
761
+ '1234-1234',
762
+ 'D0D0D0'
763
+ ]
764
+ },
765
+ HU: {
766
+ valid: %w[
767
+ 7113
768
+ 2566
769
+ 6261
770
+ 7113
771
+ ],
772
+ invalid: [
773
+ nil,
774
+ '',
775
+ 'invalid_zip',
776
+ '12345',
777
+ '1234-1234',
778
+ 'D0D0D0'
779
+ ]
780
+ },
781
+ IS: {
782
+ valid: %w[
783
+ 711
784
+ 256
785
+ 626
786
+ 711
787
+ ],
788
+ invalid: [
789
+ nil,
790
+ '',
791
+ 'invalid_zip',
792
+ '1234',
793
+ '123-123',
794
+ 'D0D0D0'
795
+ ]
796
+ },
797
+ IN: {
798
+ valid: %w[
799
+ 071134
800
+ 025663
801
+ 662612
802
+ 071135
803
+ ],
804
+ invalid: [
805
+ nil,
806
+ '',
807
+ 'invalid_zip',
808
+ '12345',
809
+ '123456-123456',
810
+ 'D0D0D0'
811
+ ]
812
+ },
813
+ ID: {
814
+ valid: %w[
815
+ 07113
816
+ 02566
817
+ 66261
818
+ ],
819
+ invalid: [
820
+ nil,
821
+ '',
822
+ 'invalid_zip',
823
+ '1234',
824
+ '12345-12345',
825
+ 'D0D0D0'
826
+ ]
827
+ },
828
+ IL: {
829
+ valid: %w[
830
+ 12345
831
+ 1234567
832
+ ],
833
+ invalid: [
834
+ nil,
835
+ '',
836
+ 'invalid_zip',
837
+ '123456'
838
+ ]
839
+ },
840
+ JO: {
841
+ valid: %w[
842
+ 07113
843
+ 02566
844
+ 66261
845
+ ],
846
+ invalid: [
847
+ nil,
848
+ '',
849
+ 'invalid_zip',
850
+ '1234',
851
+ '12345-12345',
852
+ 'D0D0D0'
853
+ ]
854
+ },
855
+ KZ: {
856
+ valid: %w[
857
+ 071134
858
+ 025663
859
+ 662612
860
+ 071135
861
+ ],
862
+ invalid: [
863
+ nil,
864
+ '',
865
+ 'invalid_zip',
866
+ '12345',
867
+ '123456-123456',
868
+ 'D0D0D0'
869
+ ]
870
+ },
871
+ KE: {
872
+ valid: %w[
873
+ 07113
874
+ 02566
875
+ 66261
876
+ ],
877
+ invalid: [
878
+ nil,
879
+ '',
880
+ 'invalid_zip',
881
+ '1234',
882
+ '12345-12345',
883
+ 'D0D0D0'
884
+ ]
885
+ },
886
+ KW: {
887
+ valid: %w[
888
+ 07113
889
+ 02566
890
+ 66261
891
+ ],
892
+ invalid: [
893
+ nil,
894
+ '',
895
+ 'invalid_zip',
896
+ '1234',
897
+ '12345-12345',
898
+ 'D0D0D0'
899
+ ]
900
+ },
901
+ LA: {
902
+ valid: %w[
903
+ 07113
904
+ 02566
905
+ 66261
906
+ ],
907
+ invalid: [
908
+ nil,
909
+ '',
910
+ 'invalid_zip',
911
+ '1234',
912
+ '12345-12345',
913
+ 'D0D0D0'
914
+ ]
915
+ },
916
+ LU: {
917
+ valid: [
918
+ 'L-5635',
919
+ 'L5635',
920
+ '5635'
921
+ ],
922
+ invalid: [
923
+ nil,
924
+ '',
925
+ 'invalid_zip',
926
+ '124',
927
+ '-1234'
928
+ ]
929
+ },
930
+ MK: {
931
+ valid: %w[
932
+ 7113
933
+ 2566
934
+ 6261
935
+ 7113
936
+ ],
937
+ invalid: [
938
+ nil,
939
+ '',
940
+ 'invalid_zip',
941
+ '12345',
942
+ '1234-1234',
943
+ 'D0D0D0'
944
+ ]
945
+ },
946
+ MY: {
947
+ valid: %w[
948
+ 07113
949
+ 02566
950
+ 66261
951
+ ],
952
+ invalid: [
953
+ nil,
954
+ '',
955
+ 'invalid_zip',
956
+ '1234',
957
+ '12345-12345',
958
+ 'D0D0D0'
959
+ ]
960
+ },
961
+ MV: {
962
+ valid: %w[
963
+ 07113
964
+ 02566
965
+ 66261
966
+ ],
967
+ invalid: [
968
+ nil,
969
+ '',
970
+ 'invalid_zip',
971
+ '1234',
972
+ '12345-12345',
973
+ 'D0D0D0'
974
+ ]
975
+ },
976
+ MT: {
977
+ valid: [
978
+ 'IDA 1234',
979
+ 'idA 1234',
980
+ 'idA1234'
981
+ ],
982
+ invalid: [
983
+ nil,
984
+ '',
985
+ 'invalid_zip',
986
+ 'nope',
987
+ 'MX92XP',
988
+ 'MX9 1234'
989
+ ]
990
+ },
991
+ MU: {
992
+ valid: %w[
993
+ 42602
994
+ A2101
995
+ r6414
996
+ ],
997
+ invalid: [
998
+ nil,
999
+ '',
1000
+ 'invalid_zip',
1001
+ '05678',
1002
+ 'B4242'
1003
+ ]
1004
+ },
1005
+ MX: {
1006
+ valid: %w[
1007
+ 07113
1008
+ 02566
1009
+ 66261
1010
+ ],
1011
+ invalid: [
1012
+ nil,
1013
+ '',
1014
+ 'invalid_zip',
1015
+ '1234',
1016
+ '12345-12345',
1017
+ 'D0D0D0'
1018
+ ]
1019
+ },
1020
+ MA: {
1021
+ valid: %w[
1022
+ 07113
1023
+ 02566
1024
+ 66261
1025
+ ],
1026
+ invalid: [
1027
+ nil,
1028
+ '',
1029
+ 'invalid_zip',
1030
+ '1234',
1031
+ '12345-12345',
1032
+ 'D0D0D0'
1033
+ ]
1034
+ },
1035
+ NZ: {
1036
+ valid: %w[
1037
+ 7113
1038
+ 2566
1039
+ 6261
1040
+ 7113
1041
+ ],
1042
+ invalid: [
1043
+ nil,
1044
+ '',
1045
+ 'invalid_zip',
1046
+ '12345',
1047
+ '1234-1234',
1048
+ 'D0D0D0'
1049
+ ]
1050
+ },
1051
+ NI: {
1052
+ valid: %w[
1053
+ 07113
1054
+ 02566
1055
+ 66261
1056
+ ],
1057
+ invalid: [
1058
+ nil,
1059
+ '',
1060
+ 'invalid_zip',
1061
+ '1234',
1062
+ '12345-12345',
1063
+ 'D0D0D0'
1064
+ ]
1065
+ },
1066
+ NG: {
1067
+ valid: %w[
1068
+ 071134
1069
+ 025663
1070
+ 662612
1071
+ 071135
1072
+ ],
1073
+ invalid: [
1074
+ nil,
1075
+ '',
1076
+ 'invalid_zip',
1077
+ '12345',
1078
+ '123456-123456',
1079
+ 'D0D0D0'
1080
+ ]
1081
+ },
1082
+ OM: {
1083
+ valid: [
1084
+ '123',
1085
+ 'PC 123',
1086
+ '847',
1087
+ 'PC 847'
1088
+ ],
1089
+ invalid: [
1090
+ nil,
1091
+ '',
1092
+ 'invalid_zip',
1093
+ '12',
1094
+ '1234',
1095
+ 'PC123'
1096
+ ]
1097
+ },
1098
+ PK: {
1099
+ valid: %w[
1100
+ 07113
1101
+ 02566
1102
+ 66261
1103
+ ],
1104
+ invalid: [
1105
+ nil,
1106
+ '',
1107
+ 'invalid_zip',
1108
+ '1234',
1109
+ '12345-12345',
1110
+ 'D0D0D0'
1111
+ ]
1112
+ },
1113
+ PY: {
1114
+ valid: %w[
1115
+ 7113
1116
+ 2566
1117
+ 6261
1118
+ 7113
1119
+ ],
1120
+ invalid: [
1121
+ nil,
1122
+ '',
1123
+ 'invalid_zip',
1124
+ '12345',
1125
+ '1234-1234',
1126
+ 'D0D0D0'
1127
+ ]
1128
+ },
1129
+ PH: {
1130
+ valid: %w[
1131
+ 7113
1132
+ 2566
1133
+ 6261
1134
+ 7113
1135
+ ],
1136
+ invalid: [
1137
+ nil,
1138
+ '',
1139
+ 'invalid_zip',
1140
+ '12345',
1141
+ '1234-1234',
1142
+ 'D0D0D0'
1143
+ ]
1144
+ },
1145
+ PL: {
1146
+ valid: [
1147
+ '12-345',
1148
+ '12 345',
1149
+ '12345',
1150
+ '54-321'
1151
+ ],
1152
+ invalid: [
1153
+ nil,
1154
+ '',
1155
+ 'invalid_zip',
1156
+ '1234',
1157
+ '123456',
1158
+ '123-45',
1159
+ '12-3456',
1160
+ '12-34'
1161
+ ]
1162
+ },
1163
+ PR: {
1164
+ valid: [
1165
+ '00731',
1166
+ '00690',
1167
+ '00690-4321',
1168
+ '00731-1234',
1169
+ '00731 1234'
1170
+ ],
1171
+ invalid: [
1172
+ nil,
1173
+ '',
1174
+ 'invalid_zip',
1175
+ '12345',
1176
+ '12345-1234',
1177
+ '12345 1234'
1178
+ ]
1179
+ },
1180
+ RO: {
1181
+ valid: %w[
1182
+ 071134
1183
+ 025663
1184
+ 662612
1185
+ 071135
1186
+ ],
1187
+ invalid: [
1188
+ nil,
1189
+ '',
1190
+ 'invalid_zip',
1191
+ '12345',
1192
+ '123456-123456',
1193
+ 'D0D0D0'
1194
+ ]
1195
+ },
1196
+ RU: {
1197
+ valid: %w[
1198
+ 071134
1199
+ 025663
1200
+ 662612
1201
+ 071135
1202
+ ],
1203
+ invalid: [
1204
+ nil,
1205
+ '',
1206
+ 'invalid_zip',
1207
+ '12345',
1208
+ '123456-123456',
1209
+ 'D0D0D0'
1210
+ ]
1211
+ },
1212
+ SM: {
1213
+ valid: %w[
1214
+ 47890
1215
+ 47895
1216
+ 47899
1217
+ ],
1218
+ invalid: [
1219
+ nil,
1220
+ '',
1221
+ 'invalid_zip',
1222
+ '12345'
1223
+ ]
1224
+ },
1225
+ SA: {
1226
+ valid: %w[
1227
+ 07113
1228
+ 02566
1229
+ 66261
1230
+ ],
1231
+ invalid: [
1232
+ nil,
1233
+ '',
1234
+ 'invalid_zip',
1235
+ '1234',
1236
+ '12345-12345',
1237
+ 'D0D0D0'
1238
+ ]
1239
+ },
1240
+ SN: {
1241
+ valid: %w[
1242
+ 07113
1243
+ 02566
1244
+ 66261
1245
+ ],
1246
+ invalid: [
1247
+ nil,
1248
+ '',
1249
+ 'invalid_zip',
1250
+ '1234',
1251
+ '12345-12345',
1252
+ 'D0D0D0'
1253
+ ]
1254
+ },
1255
+ SI: {
1256
+ valid: %w[
1257
+ 7113
1258
+ 2566
1259
+ 6261
1260
+ 7113
1261
+ ],
1262
+ invalid: [
1263
+ nil,
1264
+ '',
1265
+ 'invalid_zip',
1266
+ '12345',
1267
+ '1234-1234',
1268
+ 'D0D0D0'
1269
+ ]
1270
+ },
1271
+ ZA: {
1272
+ valid: %w[
1273
+ 7113
1274
+ 2566
1275
+ 6261
1276
+ 7113
1277
+ ],
1278
+ invalid: [
1279
+ nil,
1280
+ '',
1281
+ 'invalid_zip',
1282
+ '12345',
1283
+ '1234-1234',
1284
+ 'D0D0D0'
1285
+ ]
1286
+ },
1287
+ LK: {
1288
+ valid: %w[
1289
+ 07113
1290
+ 02566
1291
+ 66261
1292
+ ],
1293
+ invalid: [
1294
+ nil,
1295
+ '',
1296
+ 'invalid_zip',
1297
+ '1234',
1298
+ '12345-12345',
1299
+ 'D0D0D0'
1300
+ ]
1301
+ },
1302
+ TJ: {
1303
+ valid: %w[
1304
+ 071134
1305
+ 025663
1306
+ 662612
1307
+ 071135
1308
+ ],
1309
+ invalid: [
1310
+ nil,
1311
+ '',
1312
+ 'invalid_zip',
1313
+ '12345',
1314
+ '123456-123456',
1315
+ 'D0D0D0'
1316
+ ]
1317
+ },
1318
+ TH: {
1319
+ valid: %w[
1320
+ 07113
1321
+ 02566
1322
+ 66261
1323
+ ],
1324
+ invalid: [
1325
+ nil,
1326
+ '',
1327
+ 'invalid_zip',
1328
+ '1234',
1329
+ '12345-12345',
1330
+ 'D0D0D0'
1331
+ ]
1332
+ },
1333
+ TN: {
1334
+ valid: %w[
1335
+ 7113
1336
+ 2566
1337
+ 6261
1338
+ 7113
1339
+ ],
1340
+ invalid: [
1341
+ nil,
1342
+ '',
1343
+ 'invalid_zip',
1344
+ '12345',
1345
+ '1234-1234',
1346
+ 'D0D0D0'
1347
+ ]
1348
+ },
1349
+ TR: {
1350
+ valid: %w[
1351
+ 07113
1352
+ 02566
1353
+ 66261
1354
+ ],
1355
+ invalid: [
1356
+ nil,
1357
+ '',
1358
+ 'invalid_zip',
1359
+ '1234',
1360
+ '12345-12345',
1361
+ 'D0D0D0'
1362
+ ]
1363
+ },
1364
+ TM: {
1365
+ valid: %w[
1366
+ 071134
1367
+ 025663
1368
+ 662612
1369
+ 071135
1370
+ ],
1371
+ invalid: [
1372
+ nil,
1373
+ '',
1374
+ 'invalid_zip',
1375
+ '12345',
1376
+ '123456-123456',
1377
+ 'D0D0D0'
1378
+ ]
1379
+ },
1380
+ UA: {
1381
+ valid: %w[
1382
+ 07113
1383
+ 02566
1384
+ 66261
1385
+ ],
1386
+ invalid: [
1387
+ nil,
1388
+ '',
1389
+ 'invalid_zip',
1390
+ '1234',
1391
+ '12345-12345',
1392
+ 'D0D0D0'
1393
+ ]
1394
+ },
1395
+ UZ: {
1396
+ valid: %w[
1397
+ 071134
1398
+ 025663
1399
+ 662612
1400
+ 071135
1401
+ ],
1402
+ invalid: [
1403
+ nil,
1404
+ '',
1405
+ 'invalid_zip',
1406
+ '12345',
1407
+ '123456-123456',
1408
+ 'D0D0D0'
1409
+ ]
1410
+ },
1411
+ VA: {
1412
+ valid: %w[
1413
+ 00120
1414
+ ],
1415
+ invalid: [
1416
+ nil,
1417
+ '',
1418
+ 'invalid_zip',
1419
+ '12345'
1420
+ ]
1421
+ },
1422
+ VE: {
1423
+ valid: %w[
1424
+ 7113
1425
+ 2566
1426
+ 6261
1427
+ 7113
1428
+ ],
1429
+ invalid: [
1430
+ nil,
1431
+ '',
1432
+ 'invalid_zip',
1433
+ '12345',
1434
+ '1234-1234',
1435
+ 'D0D0D0'
1436
+ ]
1437
+ },
1438
+ ZM: {
1439
+ valid: %w[
1440
+ 07113
1441
+ 02566
1442
+ 66261
1443
+ ],
1444
+ invalid: [
1445
+ nil,
1446
+ '',
1447
+ 'invalid_zip',
1448
+ '1234',
1449
+ '12345-12345',
1450
+ 'D0D0D0'
1451
+ ]
1452
+ },
1453
+ AS: {
1454
+ valid: %w[
1455
+ 96799
1456
+ ],
1457
+ invalid: [
1458
+ nil,
1459
+ '',
1460
+ 'invalid_zip',
1461
+ '1234'
1462
+ ]
1463
+ },
1464
+ CC: {
1465
+ valid: %w[
1466
+ 6799
1467
+ ],
1468
+ invalid: [
1469
+ nil,
1470
+ '',
1471
+ 'invalid_zip',
1472
+ '1234'
1473
+ ]
1474
+ },
1475
+ CK: {
1476
+ valid: %w[
1477
+ 7113
1478
+ 2566
1479
+ 6261
1480
+ 7113
1481
+ ],
1482
+ invalid: [
1483
+ nil,
1484
+ '',
1485
+ 'invalid_zip',
1486
+ '12345',
1487
+ '1234-1234',
1488
+ 'D0D0D0'
1489
+ ]
1490
+ },
1491
+ RS: {
1492
+ valid: %w[
1493
+ 07113
1494
+ 02566
1495
+ 66261
1496
+ ],
1497
+ invalid: [
1498
+ nil,
1499
+ '',
1500
+ 'invalid_zip',
1501
+ '1234',
1502
+ '12345-12345',
1503
+ 'D0D0D0'
1504
+ ]
1505
+ },
1506
+ CS: {
1507
+ valid: %w[
1508
+ 07113
1509
+ 02566
1510
+ 66261
1511
+ ],
1512
+ invalid: [
1513
+ nil,
1514
+ '',
1515
+ 'invalid_zip',
1516
+ '1234',
1517
+ '12345-12345',
1518
+ 'D0D0D0'
1519
+ ]
1520
+ },
1521
+ YU: {
1522
+ valid: %w[
1523
+ 07113
1524
+ 02566
1525
+ 66261
1526
+ ],
1527
+ invalid: [
1528
+ nil,
1529
+ '',
1530
+ 'invalid_zip',
1531
+ '1234',
1532
+ '12345-12345',
1533
+ 'D0D0D0'
1534
+ ]
1535
+ },
1536
+ CX: {
1537
+ valid: %w[
1538
+ 6798
1539
+ ],
1540
+ invalid: [
1541
+ nil,
1542
+ '',
1543
+ 'invalid_zip',
1544
+ '1234'
1545
+ ]
1546
+ },
1547
+ ET: {
1548
+ valid: %w[
1549
+ 7113
1550
+ 2566
1551
+ 6261
1552
+ 7113
1553
+ ],
1554
+ invalid: [
1555
+ nil,
1556
+ '',
1557
+ 'invalid_zip',
1558
+ '12345',
1559
+ '1234-1234',
1560
+ 'D0D0D0'
1561
+ ]
1562
+ },
1563
+ FK: {
1564
+ valid: [
1565
+ 'FIQQ 1ZZ',
1566
+ 'FIQQ1ZZ'
1567
+ ],
1568
+ invalid: [
1569
+ nil,
1570
+ '',
1571
+ 'invalid_zip',
1572
+ 'XY1 5SJ'
1573
+ ]
1574
+ },
1575
+ NF: {
1576
+ valid: %w[
1577
+ 2899
1578
+ ],
1579
+ invalid: [
1580
+ nil,
1581
+ '',
1582
+ 'invalid_zip',
1583
+ '1234'
1584
+ ]
1585
+ },
1586
+ FM: {
1587
+ valid: [
1588
+ '96942',
1589
+ '96942-1234',
1590
+ '96942 1234'
1591
+ ],
1592
+ invalid: [
1593
+ nil,
1594
+ '',
1595
+ 'invalid_zip',
1596
+ '12345'
1597
+ ]
1598
+ },
1599
+ GF: {
1600
+ valid: %w[
1601
+ 97321
1602
+ 97347
1603
+ ],
1604
+ invalid: [
1605
+ nil,
1606
+ '',
1607
+ 'invalid_zip',
1608
+ '12345'
1609
+ ]
1610
+ },
1611
+ GP: {
1612
+ valid: %w[
1613
+ 97139
1614
+ 97160
1615
+ ],
1616
+ invalid: [
1617
+ nil,
1618
+ '',
1619
+ 'invalid_zip',
1620
+ '12345'
1621
+ ]
1622
+ },
1623
+ GS: {
1624
+ valid: [
1625
+ 'SIQQ 1ZZ',
1626
+ 'SIQQ1ZZ'
1627
+ ],
1628
+ invalid: [
1629
+ nil,
1630
+ '',
1631
+ 'invalid_zip',
1632
+ 'XY1 5SJ'
1633
+ ]
1634
+ },
1635
+ GU: {
1636
+ valid: [
1637
+ '96910',
1638
+ '96916',
1639
+ '96920',
1640
+ '96929',
1641
+ '96932',
1642
+ '96920-1234',
1643
+ '96920 1234'
1644
+ ],
1645
+ invalid: [
1646
+ nil,
1647
+ '',
1648
+ 'invalid_zip',
1649
+ '96940',
1650
+ '96942'
1651
+ ]
1652
+ },
1653
+ GW: {
1654
+ valid: %w[
1655
+ 7113
1656
+ 2566
1657
+ 6261
1658
+ 7113
1659
+ ],
1660
+ invalid: [
1661
+ nil,
1662
+ '',
1663
+ 'invalid_zip',
1664
+ '12345',
1665
+ '1234-1234',
1666
+ 'D0D0D0'
1667
+ ]
1668
+ },
1669
+ HM: {
1670
+ valid: %w[
1671
+ 7113
1672
+ 2566
1673
+ 6261
1674
+ 7113
1675
+ ],
1676
+ invalid: [
1677
+ nil,
1678
+ '',
1679
+ 'invalid_zip',
1680
+ '12345',
1681
+ '1234-1234',
1682
+ 'D0D0D0'
1683
+ ]
1684
+ },
1685
+ IQ: {
1686
+ valid: %w[
1687
+ 07113
1688
+ 02566
1689
+ 66261
1690
+ ],
1691
+ invalid: [
1692
+ nil,
1693
+ '',
1694
+ 'invalid_zip',
1695
+ '1234',
1696
+ '12345-12345',
1697
+ 'D0D0D0'
1698
+ ]
1699
+ },
1700
+ KG: {
1701
+ valid: %w[
1702
+ 071134
1703
+ 025663
1704
+ 662612
1705
+ 071135
1706
+ ],
1707
+ invalid: [
1708
+ nil,
1709
+ '',
1710
+ 'invalid_zip',
1711
+ '12345',
1712
+ '123456-123456',
1713
+ 'D0D0D0'
1714
+ ]
1715
+ },
1716
+ LR: {
1717
+ valid: %w[
1718
+ 7113
1719
+ 2566
1720
+ 6261
1721
+ 7113
1722
+ ],
1723
+ invalid: [
1724
+ nil,
1725
+ '',
1726
+ 'invalid_zip',
1727
+ '12345',
1728
+ '1234-1234',
1729
+ 'D0D0D0'
1730
+ ]
1731
+ },
1732
+ LS: {
1733
+ valid: %w[
1734
+ 711
1735
+ 256
1736
+ 626
1737
+ 711
1738
+ ],
1739
+ invalid: [
1740
+ nil,
1741
+ '',
1742
+ 'invalid_zip',
1743
+ '1234',
1744
+ '123-123',
1745
+ 'D0D0D0'
1746
+ ]
1747
+ },
1748
+ MG: {
1749
+ valid: %w[
1750
+ 711
1751
+ 256
1752
+ 626
1753
+ 711
1754
+ ],
1755
+ invalid: [
1756
+ nil,
1757
+ '',
1758
+ 'invalid_zip',
1759
+ '1234',
1760
+ '123-123',
1761
+ 'D0D0D0'
1762
+ ]
1763
+ },
1764
+ MN: {
1765
+ valid: %w[
1766
+ 071134
1767
+ 025663
1768
+ 662612
1769
+ 071135
1770
+ ],
1771
+ invalid: [
1772
+ nil,
1773
+ '',
1774
+ 'invalid_zip',
1775
+ '12345',
1776
+ '123456-123456',
1777
+ 'D0D0D0'
1778
+ ]
1779
+ },
1780
+ MP: {
1781
+ valid: [
1782
+ '96950',
1783
+ '96951',
1784
+ '96952',
1785
+ '96952-1234',
1786
+ '96952 1234'
1787
+ ],
1788
+ invalid: [
1789
+ nil,
1790
+ '',
1791
+ 'invalid_zip',
1792
+ '96959',
1793
+ '96952-12345'
1794
+ ]
1795
+ },
1796
+ MQ: {
1797
+ valid: %w[
1798
+ 97216
1799
+ ],
1800
+ invalid: [
1801
+ nil,
1802
+ '',
1803
+ 'invalid_zip',
1804
+ '12345'
1805
+ ]
1806
+ },
1807
+ NC: {
1808
+ valid: %w[
1809
+ 98814
1810
+ ],
1811
+ invalid: [
1812
+ nil,
1813
+ '',
1814
+ 'invalid_zip',
1815
+ '12345'
1816
+ ]
1817
+ },
1818
+ NE: {
1819
+ valid: %w[
1820
+ 7113
1821
+ 2566
1822
+ 6261
1823
+ 7113
1824
+ ],
1825
+ invalid: [
1826
+ nil,
1827
+ '',
1828
+ 'invalid_zip',
1829
+ '12345',
1830
+ '1234-1234',
1831
+ 'D0D0D0'
1832
+ ]
1833
+ },
1834
+ PF: {
1835
+ valid: %w[
1836
+ 98730
1837
+ 98733
1838
+ ],
1839
+ invalid: [
1840
+ nil,
1841
+ '',
1842
+ 'invalid_zip',
1843
+ '12345'
1844
+ ]
1845
+ },
1846
+ PG: {
1847
+ valid: %w[
1848
+ 711
1849
+ 256
1850
+ 626
1851
+ 711
1852
+ ],
1853
+ invalid: [
1854
+ nil,
1855
+ '',
1856
+ 'invalid_zip',
1857
+ '1234',
1858
+ '123-123',
1859
+ 'D0D0D0'
1860
+ ]
1861
+ },
1862
+ PM: {
1863
+ valid: %w[
1864
+ 97500
1865
+ 97502
1866
+ ],
1867
+ invalid: [
1868
+ nil,
1869
+ '',
1870
+ 'invalid_zip',
1871
+ '12345'
1872
+ ]
1873
+ },
1874
+ PN: {
1875
+ valid: [
1876
+ 'PCRN 1ZZ',
1877
+ 'PCRN1ZZ'
1878
+ ],
1879
+ invalid: [
1880
+ nil,
1881
+ '',
1882
+ 'invalid_zip',
1883
+ 'XY1 5SJ'
1884
+ ]
1885
+ },
1886
+ PW: {
1887
+ valid: %w[
1888
+ 96940
1889
+ ],
1890
+ invalid: [
1891
+ nil,
1892
+ '',
1893
+ 'invalid_zip',
1894
+ '12345'
1895
+ ]
1896
+ },
1897
+ RE: {
1898
+ valid: %w[
1899
+ 97419
1900
+ 97400
1901
+ ],
1902
+ invalid: [
1903
+ nil,
1904
+ '',
1905
+ 'invalid_zip',
1906
+ '97764',
1907
+ '97885',
1908
+ '97119',
1909
+ '98419'
1910
+ ]
1911
+ },
1912
+ SH: {
1913
+ valid: [
1914
+ 'ASCN 1ZZ',
1915
+ 'ASCN1ZZ',
1916
+ 'STHL 1ZZ',
1917
+ 'STHL1ZZ',
1918
+ 'TDCU 1ZZ',
1919
+ 'TDCU1ZZ'
1920
+ ],
1921
+ invalid: [
1922
+ nil,
1923
+ '',
1924
+ 'invalid_zip',
1925
+ 'XY1 5SJ'
1926
+ ]
1927
+ },
1928
+ SJ: {
1929
+ valid: %w[
1930
+ 7113
1931
+ 2566
1932
+ 6261
1933
+ 7113
1934
+ ],
1935
+ invalid: [
1936
+ nil,
1937
+ '',
1938
+ 'invalid_zip',
1939
+ '12345',
1940
+ '1234-1234',
1941
+ 'D0D0D0'
1942
+ ]
1943
+ },
1944
+ SZ: {
1945
+ valid: %w[
1946
+ H113
1947
+ L566
1948
+ M261
1949
+ S261
1950
+ ],
1951
+ invalid: [
1952
+ nil,
1953
+ '',
1954
+ 'invalid_zip',
1955
+ 'HM113',
1956
+ 'L34',
1957
+ 'H113-H113',
1958
+ 'D0D0D0'
1959
+ ]
1960
+ },
1961
+ TC: {
1962
+ valid: [
1963
+ 'TKCA 1ZZ',
1964
+ 'TKCA1ZZ'
1965
+ ],
1966
+ invalid: [
1967
+ nil,
1968
+ '',
1969
+ 'invalid_zip',
1970
+ 'XY1 5SJ'
1971
+ ]
1972
+ },
1973
+ WF: {
1974
+ valid: %w[
1975
+ 98613
1976
+ 98666
1977
+ 98661
1978
+ ],
1979
+ invalid: [
1980
+ nil,
1981
+ '',
1982
+ 'invalid_zip',
1983
+ '1234',
1984
+ '98666-98666',
1985
+ '12345',
1986
+ 'D0D0D0'
1987
+ ]
1988
+ },
1989
+ XK: {
1990
+ valid: %w[
1991
+ 07113
1992
+ 02566
1993
+ 66261
1994
+ ],
1995
+ invalid: [
1996
+ nil,
1997
+ '',
1998
+ 'invalid_zip',
1999
+ '1234',
2000
+ '12345-12345',
2001
+ 'D0D0D0'
2002
+ ]
2003
+ },
2004
+ YT: {
2005
+ valid: %w[
2006
+ 97613
2007
+ 97666
2008
+ 97661
2009
+ ],
2010
+ invalid: [
2011
+ nil,
2012
+ '',
2013
+ 'invalid_zip',
2014
+ '1234',
2015
+ '97666-97666',
2016
+ '12345',
2017
+ 'D0D0D0'
2018
+ ]
2019
+ },
2020
+ AF: {
2021
+ valid: %w[
2022
+ 7113
2023
+ 2566
2024
+ 6261
2025
+ 7113
2026
+ ],
2027
+ invalid: [
2028
+ nil,
2029
+ '',
2030
+ 'invalid_zip',
2031
+ '12345',
2032
+ '1234-1234',
2033
+ 'D0D0D0'
2034
+ ]
2035
+ },
2036
+ AL: {
2037
+ valid: %w[
2038
+ 7113
2039
+ 2566
2040
+ 6261
2041
+ 7113
2042
+ ],
2043
+ invalid: [
2044
+ nil,
2045
+ '',
2046
+ 'invalid_zip',
2047
+ '12345',
2048
+ '1234-1234',
2049
+ 'D0D0D0'
2050
+ ]
2051
+ },
2052
+ AG: {
2053
+ valid: %w[
2054
+ 42511
2055
+ AZ42511
2056
+ XY12Z
2057
+ A12
2058
+ 123
2059
+ ABC
2060
+ ],
2061
+ invalid: [
2062
+ nil,
2063
+ '',
2064
+ 'invalid_zip',
2065
+ 'AB',
2066
+ '12'
2067
+ ]
2068
+ },
2069
+ AO: {
2070
+ valid: %w[
2071
+ 42511
2072
+ AZ42511
2073
+ XY12Z
2074
+ A12
2075
+ 123
2076
+ ABC
2077
+ ],
2078
+ invalid: [
2079
+ nil,
2080
+ '',
2081
+ 'invalid_zip',
2082
+ 'AB',
2083
+ '12'
2084
+ ]
2085
+ },
2086
+ BF: {
2087
+ valid: %w[
2088
+ 42511
2089
+ AZ42511
2090
+ XY12Z
2091
+ A12
2092
+ 123
2093
+ ABC
2094
+ ],
2095
+ invalid: [
2096
+ nil,
2097
+ '',
2098
+ 'invalid_zip',
2099
+ 'AB',
2100
+ '12'
2101
+ ]
2102
+ },
2103
+ BI: {
2104
+ valid: %w[
2105
+ 42511
2106
+ AZ42511
2107
+ XY12Z
2108
+ A12
2109
+ 123
2110
+ ABC
2111
+ ],
2112
+ invalid: [
2113
+ nil,
2114
+ '',
2115
+ 'invalid_zip',
2116
+ 'AB',
2117
+ '12'
2118
+ ]
2119
+ },
2120
+ BS: {
2121
+ valid: %w[
2122
+ 42511
2123
+ AZ42511
2124
+ XY12Z
2125
+ A12
2126
+ 123
2127
+ ABC
2128
+ ],
2129
+ invalid: [
2130
+ nil,
2131
+ '',
2132
+ 'invalid_zip',
2133
+ 'AB',
2134
+ '12'
2135
+ ]
2136
+ },
2137
+ BZ: {
2138
+ valid: %w[
2139
+ 42511
2140
+ AZ42511
2141
+ XY12Z
2142
+ A12
2143
+ 123
2144
+ ABC
2145
+ ],
2146
+ invalid: [
2147
+ nil,
2148
+ '',
2149
+ 'invalid_zip',
2150
+ 'AB',
2151
+ '12'
2152
+ ]
2153
+ },
2154
+ BR: {
2155
+ valid: [
2156
+ '58397-000',
2157
+ '58915-000',
2158
+ '58763000',
2159
+ '58935-000',
2160
+ '12345678'
2161
+ ],
2162
+ invalid: [
2163
+ nil,
2164
+ '',
2165
+ 'invalid_zip',
2166
+ '1234',
2167
+ '123456789'
2168
+ ]
2169
+ },
2170
+ BJ: {
2171
+ valid: %w[
2172
+ 42511
2173
+ AZ42511
2174
+ XY12Z
2175
+ A12
2176
+ 123
2177
+ ABC
2178
+ ],
2179
+ invalid: [
2180
+ nil,
2181
+ '',
2182
+ 'invalid_zip',
2183
+ 'AB',
2184
+ '12'
2185
+ ]
2186
+ },
2187
+ BT: {
2188
+ valid: %w[
2189
+ 07113
2190
+ 02566
2191
+ 66261
2192
+ ],
2193
+ invalid: [
2194
+ nil,
2195
+ '',
2196
+ 'invalid_zip',
2197
+ '1234',
2198
+ '12345-12345',
2199
+ 'D0D0D0'
2200
+ ]
2201
+ },
2202
+ BQ: {
2203
+ valid: %w[
2204
+ 42511
2205
+ AZ42511
2206
+ XY12Z
2207
+ A12
2208
+ 123
2209
+ ABC
2210
+ ],
2211
+ invalid: [
2212
+ nil,
2213
+ '',
2214
+ 'invalid_zip',
2215
+ 'AB',
2216
+ '12'
2217
+ ]
2218
+ },
2219
+ BO: {
2220
+ valid: %w[
2221
+ 7113
2222
+ 2566
2223
+ 6261
2224
+ 7113
2225
+ ],
2226
+ invalid: [
2227
+ nil,
2228
+ '',
2229
+ 'invalid_zip',
2230
+ '12345',
2231
+ '1234-1234',
2232
+ 'D0D0D0'
2233
+ ]
2234
+ },
2235
+ BW: {
2236
+ valid: %w[
2237
+ 42511
2238
+ AZ42511
2239
+ XY12Z
2240
+ A12
2241
+ 123
2242
+ ABC
2243
+ ],
2244
+ invalid: [
2245
+ nil,
2246
+ '',
2247
+ 'invalid_zip',
2248
+ 'AB',
2249
+ '12'
2250
+ ]
2251
+ },
2252
+ CF: {
2253
+ valid: %w[
2254
+ 42511
2255
+ AZ42511
2256
+ XY12Z
2257
+ A12
2258
+ 123
2259
+ ABC
2260
+ ],
2261
+ invalid: [
2262
+ nil,
2263
+ '',
2264
+ 'invalid_zip',
2265
+ 'AB',
2266
+ '12'
2267
+ ]
2268
+ },
2269
+ CG: {
2270
+ valid: %w[
2271
+ 42511
2272
+ AZ42511
2273
+ XY12Z
2274
+ A12
2275
+ 123
2276
+ ABC
2277
+ ],
2278
+ invalid: [
2279
+ nil,
2280
+ '',
2281
+ 'invalid_zip',
2282
+ 'AB',
2283
+ '12'
2284
+ ]
2285
+ },
2286
+ CI: {
2287
+ valid: %w[
2288
+ 42511
2289
+ AZ42511
2290
+ XY12Z
2291
+ A12
2292
+ 123
2293
+ ABC
2294
+ ],
2295
+ invalid: [
2296
+ nil,
2297
+ '',
2298
+ 'invalid_zip',
2299
+ 'AB',
2300
+ '12'
2301
+ ]
2302
+ },
2303
+ CO: {
2304
+ valid: %w[
2305
+ 42511
2306
+ AZ42511
2307
+ XY12Z
2308
+ A12
2309
+ 123
2310
+ ABC
2311
+ ],
2312
+ invalid: [
2313
+ nil,
2314
+ '',
2315
+ 'invalid_zip',
2316
+ 'AB',
2317
+ '12'
2318
+ ]
2319
+ },
2320
+ CR: {
2321
+ valid: %w[
2322
+ 07113
2323
+ 02566
2324
+ 66261
2325
+ ],
2326
+ invalid: [
2327
+ nil,
2328
+ '',
2329
+ 'invalid_zip',
2330
+ '1234',
2331
+ '12345-12345',
2332
+ 'D0D0D0'
2333
+ ]
2334
+ },
2335
+ CU: {
2336
+ valid: %w[
2337
+ 07113
2338
+ 02566
2339
+ 66261
2340
+ ],
2341
+ invalid: [
2342
+ nil,
2343
+ '',
2344
+ 'invalid_zip',
2345
+ '1234',
2346
+ '12345-12345',
2347
+ 'D0D0D0'
2348
+ ]
2349
+ },
2350
+ KM: {
2351
+ valid: %w[
2352
+ 42511
2353
+ AZ42511
2354
+ XY12Z
2355
+ A12
2356
+ 123
2357
+ ABC
2358
+ ],
2359
+ invalid: [
2360
+ nil,
2361
+ '',
2362
+ 'invalid_zip',
2363
+ 'AB',
2364
+ '12'
2365
+ ]
2366
+ },
2367
+ DJ: {
2368
+ valid: %w[
2369
+ 42511
2370
+ AZ42511
2371
+ XY12Z
2372
+ A12
2373
+ 123
2374
+ ABC
2375
+ ],
2376
+ invalid: [
2377
+ nil,
2378
+ '',
2379
+ 'invalid_zip',
2380
+ 'AB',
2381
+ '12'
2382
+ ]
2383
+ },
2384
+ DM: {
2385
+ valid: %w[
2386
+ 42511
2387
+ AZ42511
2388
+ XY12Z
2389
+ A12
2390
+ 123
2391
+ ABC
2392
+ ],
2393
+ invalid: [
2394
+ nil,
2395
+ '',
2396
+ 'invalid_zip',
2397
+ 'AB',
2398
+ '12'
2399
+ ]
2400
+ },
2401
+ EG: {
2402
+ valid: %w[
2403
+ 42511
2404
+ AZ42511
2405
+ XY12Z
2406
+ A12
2407
+ 123
2408
+ ABC
2409
+ ],
2410
+ invalid: [
2411
+ nil,
2412
+ '',
2413
+ 'invalid_zip',
2414
+ 'AB',
2415
+ '12'
2416
+ ]
2417
+ },
2418
+ GQ: {
2419
+ valid: %w[
2420
+ 42511
2421
+ AZ42511
2422
+ XY12Z
2423
+ A12
2424
+ 123
2425
+ ABC
2426
+ ],
2427
+ invalid: [
2428
+ nil,
2429
+ '',
2430
+ 'invalid_zip',
2431
+ 'AB',
2432
+ '12'
2433
+ ]
2434
+ },
2435
+ EL: {
2436
+ valid: %w[
2437
+ 07113
2438
+ 02566
2439
+ 66261
2440
+ ],
2441
+ invalid: [
2442
+ nil,
2443
+ '',
2444
+ 'invalid_zip',
2445
+ '1234',
2446
+ '12345-12345',
2447
+ 'D0D0D0'
2448
+ ]
2449
+ },
2450
+ ER: {
2451
+ valid: %w[
2452
+ 42511
2453
+ AZ42511
2454
+ XY12Z
2455
+ A12
2456
+ 123
2457
+ ABC
2458
+ ],
2459
+ invalid: [
2460
+ nil,
2461
+ '',
2462
+ 'invalid_zip',
2463
+ 'AB',
2464
+ '12'
2465
+ ]
2466
+ },
2467
+ FJ: {
2468
+ valid: %w[
2469
+ 42511
2470
+ AZ42511
2471
+ XY12Z
2472
+ A12
2473
+ 123
2474
+ ABC
2475
+ ],
2476
+ invalid: [
2477
+ nil,
2478
+ '',
2479
+ 'invalid_zip',
2480
+ 'AB',
2481
+ '12'
2482
+ ]
2483
+ },
2484
+ FR: {
2485
+ valid: %w[
2486
+ 07113
2487
+ 02566
2488
+ 66261
2489
+ ],
2490
+ invalid: [
2491
+ nil,
2492
+ '',
2493
+ 'invalid_zip',
2494
+ '1234',
2495
+ '12345-12345',
2496
+ 'D0D0D0'
2497
+ ]
2498
+ },
2499
+ GA: {
2500
+ valid: %w[
2501
+ 7113
2502
+ 2566
2503
+ 6261
2504
+ 7113
2505
+ ],
2506
+ invalid: [
2507
+ nil,
2508
+ '',
2509
+ 'invalid_zip',
2510
+ '12345',
2511
+ '1234-1234',
2512
+ 'D0D0D0'
2513
+ ]
2514
+ },
2515
+ GD: {
2516
+ valid: %w[
2517
+ 42511
2518
+ AZ42511
2519
+ XY12Z
2520
+ A12
2521
+ 123
2522
+ ABC
2523
+ ],
2524
+ invalid: [
2525
+ nil,
2526
+ '',
2527
+ 'invalid_zip',
2528
+ 'AB',
2529
+ '12'
2530
+ ]
2531
+ },
2532
+ GH: {
2533
+ valid: %w[
2534
+ 42511
2535
+ AZ42511
2536
+ XY12Z
2537
+ A12
2538
+ 123
2539
+ ABC
2540
+ ],
2541
+ invalid: [
2542
+ nil,
2543
+ '',
2544
+ 'invalid_zip',
2545
+ 'AB',
2546
+ '12'
2547
+ ]
2548
+ },
2549
+ GM: {
2550
+ valid: %w[
2551
+ 42511
2552
+ AZ42511
2553
+ XY12Z
2554
+ A12
2555
+ 123
2556
+ ABC
2557
+ ],
2558
+ invalid: [
2559
+ nil,
2560
+ '',
2561
+ 'invalid_zip',
2562
+ 'AB',
2563
+ '12'
2564
+ ]
2565
+ },
2566
+ GN: {
2567
+ valid: %w[
2568
+ 42511
2569
+ AZ42511
2570
+ XY12Z
2571
+ A12
2572
+ 123
2573
+ ABC
2574
+ ],
2575
+ invalid: [
2576
+ nil,
2577
+ '',
2578
+ 'invalid_zip',
2579
+ 'AB',
2580
+ '12'
2581
+ ]
2582
+ },
2583
+ GI: {
2584
+ valid: [
2585
+ 'GX11 1AA',
2586
+ 'GX111AA'
2587
+ ],
2588
+ invalid: [
2589
+ nil,
2590
+ '',
2591
+ 'invalid_zip',
2592
+ 'XY1 5SJ'
2593
+ ]
2594
+ },
2595
+ GR: {
2596
+ valid: [
2597
+ '048 80',
2598
+ '50039',
2599
+ '67183'
2600
+ ],
2601
+ invalid: [
2602
+ nil,
2603
+ '',
2604
+ 'invalid_zip',
2605
+ '123456'
2606
+ ]
2607
+ },
2608
+ GY: {
2609
+ valid: %w[
2610
+ 42511
2611
+ AZ42511
2612
+ XY12Z
2613
+ A12
2614
+ 123
2615
+ ABC
2616
+ ],
2617
+ invalid: [
2618
+ nil,
2619
+ '',
2620
+ 'invalid_zip',
2621
+ 'AB',
2622
+ '12'
2623
+ ]
2624
+ },
2625
+ HN: {
2626
+ valid: %w[
2627
+ BV2722
2628
+ XY1234
2629
+ ],
2630
+ invalid: [
2631
+ nil,
2632
+ '',
2633
+ 'invalid_zip',
2634
+ 'B2722',
2635
+ 'XY12345',
2636
+ 'XY123'
2637
+ ]
2638
+ },
2639
+ IO: {
2640
+ valid: %w[
2641
+ 07113
2642
+ 02566
2643
+ 66261
2644
+ ],
2645
+ invalid: [
2646
+ nil,
2647
+ '',
2648
+ 'invalid_zip',
2649
+ '1234',
2650
+ '12345-12345',
2651
+ 'D0D0D0'
2652
+ ]
2653
+ },
2654
+ IR: {
2655
+ valid: %w[
2656
+ 07113
2657
+ 02566
2658
+ 66261
2659
+ ],
2660
+ invalid: [
2661
+ nil,
2662
+ '',
2663
+ 'invalid_zip',
2664
+ '1234',
2665
+ '12345-12345',
2666
+ 'D0D0D0'
2667
+ ]
2668
+ },
2669
+ JP: {
2670
+ valid: [
2671
+ '1029200',
2672
+ '102-9200',
2673
+ '408-0301',
2674
+ '207-1000'
2675
+ ],
2676
+ invalid: [
2677
+ nil,
2678
+ '',
2679
+ 'invalid_zip',
2680
+ '1200'
2681
+ ]
2682
+ },
2683
+ JM: {
2684
+ valid: [
2685
+ nil,
2686
+ '',
2687
+ '00',
2688
+ 'JMDEH01',
2689
+ 'JMCJS10',
2690
+ 'JMDWD08',
2691
+ 'JMCAN20',
2692
+ 'JMDCN29'
2693
+ ],
2694
+ invalid: %w[
2695
+ invalid_zip
2696
+ JMDEH00
2697
+ JMDWD30
2698
+ JMDWD31
2699
+ JMDCN91
2700
+ JMXYZ05
2701
+ ]
2702
+ },
2703
+ KI: {
2704
+ valid: %w[
2705
+ KI0111
2706
+ KI0222
2707
+ KI0333
2708
+ ],
2709
+ invalid: [
2710
+ nil,
2711
+ '',
2712
+ 'KI0000',
2713
+ 'KI0444',
2714
+ 'KI2181',
2715
+ 'KI6376',
2716
+ 'KI4702',
2717
+ 'invalid_zip',
2718
+ 'KI281',
2719
+ 'KI63726',
2720
+ 'IK4702'
2721
+ ]
2722
+ },
2723
+ KN: {
2724
+ valid: %w[
2725
+ KN2181
2726
+ KN6376
2727
+ KN4702
2728
+ ],
2729
+ invalid: [
2730
+ nil,
2731
+ '',
2732
+ 'invalid_zip',
2733
+ 'KN281',
2734
+ 'KN63726',
2735
+ 'NK4702'
2736
+ ]
2737
+ },
2738
+ KP: {
2739
+ valid: %w[
2740
+ 123
2741
+ ABC
2742
+ 12345678
2743
+ 123sd678
2744
+ ],
2745
+ invalid: [
2746
+ nil,
2747
+ '',
2748
+ 'invalid_zip',
2749
+ '12',
2750
+ 'AB',
2751
+ '123456789',
2752
+ '12f3sd678'
2753
+ ]
2754
+ },
2755
+ LI: {
2756
+ valid: %w[
2757
+ 7113
2758
+ 2566
2759
+ 6261
2760
+ 7113
2761
+ ],
2762
+ invalid: [
2763
+ nil,
2764
+ '',
2765
+ 'invalid_zip',
2766
+ '12345',
2767
+ '1234-1234',
2768
+ 'D0D0D0'
2769
+ ]
2770
+ },
2771
+ LV: {
2772
+ valid: [
2773
+ 'LV-1234',
2774
+ 'LV-8735',
2775
+ '8735'
2776
+ ],
2777
+ invalid: [
2778
+ nil,
2779
+ '',
2780
+ 'invalid_zip',
2781
+ 'LV-12345',
2782
+ 'LV-123',
2783
+ 'L-1234',
2784
+ '123'
2785
+ ]
2786
+ },
2787
+ LY: {
2788
+ valid: %w[
2789
+ 07113
2790
+ 02566
2791
+ 66261
2792
+ ],
2793
+ invalid: [
2794
+ nil,
2795
+ '',
2796
+ 'invalid_zip',
2797
+ '1234',
2798
+ '12345-12345',
2799
+ 'D0D0D0'
2800
+ ]
2801
+ },
2802
+ LT: {
2803
+ valid: [
2804
+ 'LT-00110',
2805
+ 'LT 00110',
2806
+ 'LT21006',
2807
+ '00110'
2808
+ ],
2809
+ invalid: [
2810
+ nil,
2811
+ '',
2812
+ 'invalid_zip',
2813
+ 'LT-2100',
2814
+ '2100'
2815
+ ]
2816
+ },
2817
+ LC: {
2818
+ valid: %w[
2819
+ 42511
2820
+ AZ42511
2821
+ XY12Z
2822
+ A12
2823
+ 123
2824
+ ABC
2825
+ ],
2826
+ invalid: [
2827
+ nil,
2828
+ '',
2829
+ 'invalid_zip',
2830
+ 'AB',
2831
+ '12'
2832
+ ]
2833
+ },
2834
+ MC: {
2835
+ valid: %w[
2836
+ 07113
2837
+ 02566
2838
+ 66261
2839
+ ],
2840
+ invalid: [
2841
+ nil,
2842
+ '',
2843
+ 'invalid_zip',
2844
+ '1234',
2845
+ '12345-12345',
2846
+ 'D0D0D0'
2847
+ ]
2848
+ },
2849
+ MD: {
2850
+ valid: %w[
2851
+ MD2001
2852
+ ],
2853
+ invalid: [
2854
+ nil,
2855
+ '',
2856
+ 'invalid_zip',
2857
+ 'MD-2100'
2858
+ ]
2859
+ },
2860
+ ME: {
2861
+ valid: %w[
2862
+ 42511
2863
+ AZ42511
2864
+ XY12Z
2865
+ A12
2866
+ 123
2867
+ ABC
2868
+ ],
2869
+ invalid: [
2870
+ nil,
2871
+ '',
2872
+ 'invalid_zip',
2873
+ 'AB',
2874
+ '12'
2875
+ ]
2876
+ },
2877
+ MH: {
2878
+ valid: %w[
2879
+ 07113
2880
+ 02566
2881
+ 66261
2882
+ ],
2883
+ invalid: [
2884
+ nil,
2885
+ '',
2886
+ 'invalid_zip',
2887
+ '1234',
2888
+ '12345-12345',
2889
+ 'D0D0D0'
2890
+ ]
2891
+ },
2892
+ MR: {
2893
+ valid: %w[
2894
+ 42511
2895
+ AZ42511
2896
+ XY12Z
2897
+ A12
2898
+ 123
2899
+ ABC
2900
+ ],
2901
+ invalid: [
2902
+ nil,
2903
+ '',
2904
+ 'invalid_zip',
2905
+ 'AB',
2906
+ '12'
2907
+ ]
2908
+ },
2909
+ MM: {
2910
+ valid: %w[
2911
+ 42511
2912
+ AZ42511
2913
+ XY12Z
2914
+ A12
2915
+ 123
2916
+ ABC
2917
+ ],
2918
+ invalid: [
2919
+ nil,
2920
+ '',
2921
+ 'invalid_zip',
2922
+ 'AB',
2923
+ '12'
2924
+ ]
2925
+ },
2926
+ MW: {
2927
+ valid: %w[
2928
+ 42511
2929
+ AZ42511
2930
+ XY12Z
2931
+ A12
2932
+ 123
2933
+ ABC
2934
+ ],
2935
+ invalid: [
2936
+ nil,
2937
+ '',
2938
+ 'invalid_zip',
2939
+ 'AB',
2940
+ '12'
2941
+ ]
2942
+ },
2943
+ MZ: {
2944
+ valid: %w[
2945
+ 7113
2946
+ 2566
2947
+ 6261
2948
+ 7113
2949
+ ],
2950
+ invalid: [
2951
+ nil,
2952
+ '',
2953
+ 'invalid_zip',
2954
+ '12345',
2955
+ '1234-1234',
2956
+ 'D0D0D0'
2957
+ ]
2958
+ },
2959
+ NA: {
2960
+ valid: %w[
2961
+ 07113
2962
+ 02566
2963
+ 66261
2964
+ ],
2965
+ invalid: [
2966
+ nil,
2967
+ '',
2968
+ 'invalid_zip',
2969
+ '1234',
2970
+ '12345-12345',
2971
+ 'D0D0D0'
2972
+ ]
2973
+ },
2974
+ NP: {
2975
+ valid: %w[
2976
+ 071134
2977
+ 025663
2978
+ 662612
2979
+ 071135
2980
+ ],
2981
+ invalid: [
2982
+ nil,
2983
+ '',
2984
+ 'invalid_zip',
2985
+ '12345',
2986
+ '123456-123456',
2987
+ 'D0D0D0'
2988
+ ]
2989
+ },
2990
+ NR: {
2991
+ valid: %w[
2992
+ 42511
2993
+ AZ42511
2994
+ XY12Z
2995
+ A12
2996
+ 123
2997
+ ABC
2998
+ ],
2999
+ invalid: [
3000
+ nil,
3001
+ '',
3002
+ 'invalid_zip',
3003
+ 'AB',
3004
+ '12'
3005
+ ]
3006
+ },
3007
+ PT: {
3008
+ valid: [
3009
+ '4500',
3010
+ '4500-250'
3011
+ ],
3012
+ invalid: [
3013
+ nil,
3014
+ '',
3015
+ 'invalid_zip',
3016
+ '4500-2500'
3017
+ ]
3018
+ },
3019
+ PS: {
3020
+ valid: %w[
3021
+ 711
3022
+ 256
3023
+ 626
3024
+ 711
3025
+ ],
3026
+ invalid: [
3027
+ nil,
3028
+ '',
3029
+ 'invalid_zip',
3030
+ '1234',
3031
+ '123-123',
3032
+ 'D0D0D0'
3033
+ ]
3034
+ },
3035
+ PA: {
3036
+ valid: %w[
3037
+ 7113
3038
+ 2566
3039
+ 6261
3040
+ 7113
3041
+ ],
3042
+ invalid: [
3043
+ nil,
3044
+ '',
3045
+ 'invalid_zip',
3046
+ '12345',
3047
+ '1234-1234',
3048
+ 'D0D0D0'
3049
+ ]
3050
+ },
3051
+ PE: {
3052
+ valid: %w[
3053
+ 07113
3054
+ 02566
3055
+ 66261
3056
+ ],
3057
+ invalid: [
3058
+ nil,
3059
+ '',
3060
+ 'invalid_zip',
3061
+ '1234',
3062
+ '12345-12345',
3063
+ 'D0D0D0'
3064
+ ]
3065
+ },
3066
+ QA: {
3067
+ valid: %w[
3068
+ 42511
3069
+ AZ42511
3070
+ XY12Z
3071
+ A12
3072
+ 123
3073
+ ABC
3074
+ ],
3075
+ invalid: [
3076
+ nil,
3077
+ '',
3078
+ 'invalid_zip',
3079
+ 'AB',
3080
+ '12'
3081
+ ]
3082
+ },
3083
+ RW: {
3084
+ valid: %w[
3085
+ 42511
3086
+ AZ42511
3087
+ XY12Z
3088
+ A12
3089
+ 123
3090
+ ABC
3091
+ ],
3092
+ invalid: [
3093
+ nil,
3094
+ '',
3095
+ 'invalid_zip',
3096
+ 'AB',
3097
+ '12'
3098
+ ]
3099
+ },
3100
+ SC: {
3101
+ valid: %w[
3102
+ 42511
3103
+ AZ42511
3104
+ XY12Z
3105
+ A12
3106
+ 123
3107
+ ABC
3108
+ ],
3109
+ invalid: [
3110
+ nil,
3111
+ '',
3112
+ 'invalid_zip',
3113
+ 'AB',
3114
+ '12'
3115
+ ]
3116
+ },
3117
+ SE: {
3118
+ valid: [
3119
+ '048 80',
3120
+ '50039',
3121
+ '67183'
3122
+ ],
3123
+ invalid: [
3124
+ nil,
3125
+ '',
3126
+ 'invalid_zip',
3127
+ '123456'
3128
+ ]
3129
+ },
3130
+ SK: {
3131
+ valid: [
3132
+ '83102',
3133
+ '911 05',
3134
+ '094 12'
3135
+ ],
3136
+ invalid: [
3137
+ nil,
3138
+ '',
3139
+ 'invalid_zip',
3140
+ '120 00'
3141
+ ]
3142
+ },
3143
+ SL: {
3144
+ valid: %w[
3145
+ 42511
3146
+ AZ42511
3147
+ XY12Z
3148
+ A12
3149
+ 123
3150
+ ABC
3151
+ ],
3152
+ invalid: [
3153
+ nil,
3154
+ '',
3155
+ 'invalid_zip',
3156
+ 'AB',
3157
+ '12'
3158
+ ]
3159
+ },
3160
+ SB: {
3161
+ valid: %w[
3162
+ 42511
3163
+ AZ42511
3164
+ XY12Z
3165
+ A12
3166
+ 123
3167
+ ABC
3168
+ ],
3169
+ invalid: [
3170
+ nil,
3171
+ '',
3172
+ 'invalid_zip',
3173
+ 'AB',
3174
+ '12'
3175
+ ]
3176
+ },
3177
+ SR: {
3178
+ valid: %w[
3179
+ 42511
3180
+ AZ42511
3181
+ XY12Z
3182
+ A12
3183
+ 123
3184
+ ABC
3185
+ ],
3186
+ invalid: [
3187
+ nil,
3188
+ '',
3189
+ 'invalid_zip',
3190
+ 'AB',
3191
+ '12'
3192
+ ]
3193
+ },
3194
+ SO: {
3195
+ valid: %w[
3196
+ 42511
3197
+ AZ42511
3198
+ XY12Z
3199
+ A12
3200
+ 123
3201
+ ABC
3202
+ ],
3203
+ invalid: [
3204
+ nil,
3205
+ '',
3206
+ 'invalid_zip',
3207
+ 'AB',
3208
+ '12'
3209
+ ]
3210
+ },
3211
+ SV: {
3212
+ valid: %w[
3213
+ 42511
3214
+ AZ42511
3215
+ XY12Z
3216
+ A12
3217
+ 123
3218
+ ABC
3219
+ ],
3220
+ invalid: [
3221
+ nil,
3222
+ '',
3223
+ 'invalid_zip',
3224
+ 'AB',
3225
+ '12'
3226
+ ]
3227
+ },
3228
+ SD: {
3229
+ valid: %w[
3230
+ 07113
3231
+ 02566
3232
+ 66261
3233
+ ],
3234
+ invalid: [
3235
+ nil,
3236
+ '',
3237
+ 'invalid_zip',
3238
+ '1234',
3239
+ '12345-12345',
3240
+ 'D0D0D0'
3241
+ ]
3242
+ },
3243
+ ST: {
3244
+ valid: %w[
3245
+ 42511
3246
+ AZ42511
3247
+ XY12Z
3248
+ A12
3249
+ 123
3250
+ ABC
3251
+ ],
3252
+ invalid: [
3253
+ nil,
3254
+ '',
3255
+ 'invalid_zip',
3256
+ 'AB',
3257
+ '12'
3258
+ ]
3259
+ },
3260
+ SY: {
3261
+ valid: %w[
3262
+ 42511
3263
+ AZ42511
3264
+ XY12Z
3265
+ A12
3266
+ 123
3267
+ ABC
3268
+ ],
3269
+ invalid: [
3270
+ nil,
3271
+ '',
3272
+ 'invalid_zip',
3273
+ 'AB',
3274
+ '12'
3275
+ ]
3276
+ },
3277
+ SS: {
3278
+ valid: %w[
3279
+ 07113
3280
+ 02566
3281
+ 66261
3282
+ ],
3283
+ invalid: [
3284
+ nil,
3285
+ '',
3286
+ 'invalid_zip',
3287
+ '1234',
3288
+ '12345-12345',
3289
+ 'D0D0D0'
3290
+ ]
3291
+ },
3292
+ TD: {
3293
+ valid: %w[
3294
+ 07113
3295
+ 02566
3296
+ 66261
3297
+ ],
3298
+ invalid: [
3299
+ nil,
3300
+ '',
3301
+ 'invalid_zip',
3302
+ '1234',
3303
+ '12345-12345',
3304
+ 'D0D0D0'
3305
+ ]
3306
+ },
3307
+ TG: {
3308
+ valid: %w[
3309
+ 42511
3310
+ AZ42511
3311
+ XY12Z
3312
+ A12
3313
+ 123
3314
+ ABC
3315
+ ],
3316
+ invalid: [
3317
+ nil,
3318
+ '',
3319
+ 'invalid_zip',
3320
+ 'AB',
3321
+ '12'
3322
+ ]
3323
+ },
3324
+ TO: {
3325
+ valid: %w[
3326
+ 42511
3327
+ AZ42511
3328
+ XY12Z
3329
+ A12
3330
+ 123
3331
+ ABC
3332
+ ],
3333
+ invalid: [
3334
+ nil,
3335
+ '',
3336
+ 'invalid_zip',
3337
+ 'AB',
3338
+ '12'
3339
+ ]
3340
+ },
3341
+ TZ: {
3342
+ valid: %w[
3343
+ 42511
3344
+ AZ42511
3345
+ XY12Z
3346
+ A12
3347
+ 123
3348
+ ABC
3349
+ ],
3350
+ invalid: [
3351
+ nil,
3352
+ '',
3353
+ 'invalid_zip',
3354
+ 'AB',
3355
+ '12'
3356
+ ]
3357
+ },
3358
+ TT: {
3359
+ valid: %w[
3360
+ 071134
3361
+ 025663
3362
+ 662612
3363
+ 071135
3364
+ ],
3365
+ invalid: [
3366
+ nil,
3367
+ '',
3368
+ 'invalid_zip',
3369
+ '12345',
3370
+ '123456-123456',
3371
+ 'D0D0D0'
3372
+ ]
3373
+ },
3374
+ TW: {
3375
+ valid: %w[
3376
+ 833
3377
+ 74144
3378
+ ],
3379
+ invalid: [
3380
+ nil,
3381
+ '',
3382
+ 'invalid_zip',
3383
+ '4329'
3384
+ ]
3385
+ },
3386
+ UG: {
3387
+ valid: %w[
3388
+ 42511
3389
+ AZ42511
3390
+ XY12Z
3391
+ A12
3392
+ 123
3393
+ ABC
3394
+ ],
3395
+ invalid: [
3396
+ nil,
3397
+ '',
3398
+ 'invalid_zip',
3399
+ 'AB',
3400
+ '12'
3401
+ ]
3402
+ },
3403
+ UM: {
3404
+ valid: %w[
3405
+ 42511
3406
+ AZ42511
3407
+ XY12Z
3408
+ A12
3409
+ 123
3410
+ ABC
3411
+ ],
3412
+ invalid: [
3413
+ nil,
3414
+ '',
3415
+ 'invalid_zip',
3416
+ 'AB',
3417
+ '12'
3418
+ ]
3419
+ },
3420
+ UY: {
3421
+ valid: %w[
3422
+ 42511
3423
+ AZ42511
3424
+ XY12Z
3425
+ A12
3426
+ 123
3427
+ ABC
3428
+ ],
3429
+ invalid: [
3430
+ nil,
3431
+ '',
3432
+ 'invalid_zip',
3433
+ 'AB',
3434
+ '12'
3435
+ ]
3436
+ },
3437
+ VC: {
3438
+ valid: %w[
3439
+ VC2181
3440
+ VC6376
3441
+ VC4702
3442
+ ],
3443
+ invalid: [
3444
+ nil,
3445
+ '',
3446
+ 'invalid_zip',
3447
+ 'VC281',
3448
+ 'VC63726',
3449
+ 'CV4702'
3450
+ ]
3451
+ },
3452
+ VI: {
3453
+ valid: %w[
3454
+ 07113
3455
+ 02566
3456
+ 66261
3457
+ ],
3458
+ invalid: [
3459
+ nil,
3460
+ '',
3461
+ 'invalid_zip',
3462
+ '1234',
3463
+ '12345-12345',
3464
+ 'D0D0D0'
3465
+ ]
3466
+ },
3467
+ VG: {
3468
+ valid: %w[
3469
+ 42511
3470
+ AZ42511
3471
+ XY12Z
3472
+ A12
3473
+ 123
3474
+ ABC
3475
+ ],
3476
+ invalid: [
3477
+ nil,
3478
+ '',
3479
+ 'invalid_zip',
3480
+ 'AB',
3481
+ '12'
3482
+ ]
3483
+ },
3484
+ VN: {
3485
+ valid: %w[
3486
+ 071134
3487
+ 025663
3488
+ 662612
3489
+ 071135
3490
+ ],
3491
+ invalid: [
3492
+ nil,
3493
+ '',
3494
+ 'invalid_zip',
3495
+ '12345',
3496
+ '123456-123456',
3497
+ 'D0D0D0'
3498
+ ]
3499
+ },
3500
+ VU: {
3501
+ valid: %w[
3502
+ 42511
3503
+ AZ42511
3504
+ XY12Z
3505
+ A12
3506
+ 123
3507
+ ABC
3508
+ ],
3509
+ invalid: [
3510
+ nil,
3511
+ '',
3512
+ 'invalid_zip',
3513
+ 'AB',
3514
+ '12'
3515
+ ]
3516
+ },
3517
+ WS: {
3518
+ valid: %w[
3519
+ 42511
3520
+ AZ42511
3521
+ XY12Z
3522
+ A12
3523
+ 123
3524
+ ABC
3525
+ ],
3526
+ invalid: [
3527
+ nil,
3528
+ '',
3529
+ 'invalid_zip',
3530
+ 'AB',
3531
+ '12'
3532
+ ]
3533
+ },
3534
+ YE: {
3535
+ valid: %w[
3536
+ 42511
3537
+ AZ42511
3538
+ XY12Z
3539
+ A12
3540
+ 123
3541
+ ABC
3542
+ ],
3543
+ invalid: [
3544
+ nil,
3545
+ '',
3546
+ 'invalid_zip',
3547
+ 'AB',
3548
+ '12'
3549
+ ]
3550
+ },
3551
+ ZW: {
3552
+ valid: %w[
3553
+ 42511
3554
+ AZ42511
3555
+ XY12Z
3556
+ A12
3557
+ 123
3558
+ ABC
3559
+ ],
3560
+ invalid: [
3561
+ nil,
3562
+ '',
3563
+ 'invalid_zip',
3564
+ 'AB',
3565
+ '12'
3566
+ ]
3567
+ }
3568
+ }.freeze