-
Notifications
You must be signed in to change notification settings - Fork 16
/
address_test.go
3745 lines (3709 loc) · 71.2 KB
/
address_test.go
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package address
import (
"errors"
"reflect"
"testing"
"github.com/hashicorp/go-multierror"
)
func TestAddressIsZero(t *testing.T) {
tests := []struct {
Address Address
IsZero bool
}{
{
Address: Address{},
IsZero: true,
},
{
Address: Address{
Name: "John Smith",
},
IsZero: false,
},
{
Address: Address{
Organization: "Company Pty Ltd",
},
IsZero: false,
},
{
Address: Address{
StreetAddress: []string{
"525 Collins Street",
},
},
IsZero: false,
},
{
Address: Address{
DependentLocality: "test",
},
IsZero: false,
},
{
Address: Address{
Locality: "Melbourne",
},
IsZero: false,
},
{
Address: Address{
AdministrativeArea: "VIC",
},
IsZero: false,
},
{
Address: Address{
PostCode: "3000",
},
IsZero: false,
},
{
Address: Address{
Country: "AU",
},
IsZero: false,
},
{
Address: Address{
SortingCode: "1234",
},
IsZero: false,
},
{
Address: Address{
Name: "John Smith",
Organization: "Company Pty Ltd",
StreetAddress: []string{
"525 Collins Street",
},
Locality: "Melbourne",
AdministrativeArea: "VIC",
PostCode: "3000",
Country: "AU",
},
IsZero: false,
},
}
for i, testCase := range tests {
isZero := testCase.Address.IsZero()
if isZero != testCase.IsZero {
t.Errorf("Result for IsZero() in test case %d does not match expected result", i)
}
}
}
func TestValidAddresses(t *testing.T) {
tests := []struct {
Address []func(*Address)
Expected Address
}{
{
Address: []func(*Address){
WithName("John Smith"),
WithOrganization("Company Pty Ltd"),
WithStreetAddress([]string{
"525 Collins Street",
}),
WithLocality("Melbourne"),
WithAdministrativeArea("VIC"),
WithPostCode("3000"),
WithCountry("AU"),
},
Expected: Address{
Country: "AU",
Name: "John Smith",
Organization: "Company Pty Ltd",
StreetAddress: []string{
"525 Collins Street",
},
Locality: "Melbourne",
AdministrativeArea: "VIC",
PostCode: "3000",
},
},
{
Address: []func(*Address){
WithStreetAddress([]string{
"525 Collins Street",
}),
WithLocality("Melbourne"),
WithAdministrativeArea("VIC"),
WithPostCode("3000"),
WithCountry("AU"),
},
Expected: Address{
Country: "AU",
StreetAddress: []string{
"525 Collins Street",
},
Locality: "Melbourne",
AdministrativeArea: "VIC",
PostCode: "3000",
},
},
{
Address: []func(*Address){
WithStreetAddress([]string{
"27 Rue Pasteur",
}),
WithLocality("Cabourg"),
WithPostCode("14390"),
WithCountry("FR"),
},
Expected: Address{
Country: "FR",
StreetAddress: []string{
"27 Rue Pasteur",
},
Locality: "Cabourg",
PostCode: "14390",
},
},
{
Address: []func(*Address){
WithStreetAddress([]string{
"27 Rue Pasteur",
}),
WithLocality("Cabourg"),
WithPostCode("14390"),
WithCountry("FR"),
},
Expected: Address{
Country: "FR",
StreetAddress: []string{
"27 Rue Pasteur",
},
Locality: "Cabourg",
PostCode: "14390",
},
},
{
Address: []func(*Address){
WithName("PFC John Smith"),
WithStreetAddress([]string{
"PSC 1234, Box 12345",
}),
WithLocality("APO"),
WithAdministrativeArea("AE"),
WithPostCode("09204-1234"),
WithCountry("US"),
},
Expected: Address{
Country: "US",
Name: "PFC John Smith",
StreetAddress: []string{
"PSC 1234, Box 12345",
},
Locality: "APO",
AdministrativeArea: "AE",
PostCode: "09204-1234",
},
},
{
Address: []func(*Address){
WithStreetAddress([]string{
"No.1 Jianguomenwai Avenue",
}),
WithDependentLocality("临翔区"),
WithLocality("临沧市"),
WithAdministrativeArea("53"),
WithPostCode("677000"),
WithCountry("CN"),
},
Expected: Address{
Country: "CN",
StreetAddress: []string{
"No.1 Jianguomenwai Avenue",
},
DependentLocality: "临翔区",
Locality: "临沧市",
AdministrativeArea: "53",
PostCode: "677000",
},
},
{
Address: []func(*Address){
WithStreetAddress([]string{
"Jangnyang-ro 17beon-gil",
}),
WithDependentLocality("북구"),
WithLocality("포항시"),
WithAdministrativeArea("47"),
WithPostCode("37592"), // Invalid post code
WithCountry("KR"),
},
Expected: Address{
Country: "KR",
StreetAddress: []string{
"Jangnyang-ro 17beon-gil",
},
DependentLocality: "북구",
Locality: "포항시",
AdministrativeArea: "47",
PostCode: "37592",
},
},
}
for i, testCase := range tests {
address, err := NewValid(testCase.Address...)
if err != nil {
t.Fatalf("Error creating valid address using test case %d: %s", i, err)
}
if !reflect.DeepEqual(address, testCase.Expected) {
t.Errorf("Address in test case %d does not match expected address", i)
}
}
}
func TestInvalidAddresses(t *testing.T) {
tests := []struct {
Address []func(*Address)
}{
{
Address: []func(*Address){
WithName("John Smith"),
WithOrganization("Company Pty Ltd"),
WithStreetAddress([]string{
"525 Collins Street",
}),
WithLocality("Melbourne"),
WithAdministrativeArea("VIC"),
WithPostCode("2000"), // Invalid post code
WithCountry("AU"),
},
},
{
Address: []func(*Address){
WithName("John Smith"),
WithOrganization("Company Pty Ltd"),
WithStreetAddress([]string{
"525 Collins Street",
}),
WithLocality("Melbourne"),
WithAdministrativeArea("VIC"),
WithPostCode("VIC 3000"), // Invalid post code
WithCountry("AU"),
},
},
{
Address: []func(*Address){
WithName("John Smith"),
WithOrganization("Company Pty Ltd"),
WithStreetAddress([]string{
"525 Collins Street",
}),
WithLocality("Melbourne"),
WithAdministrativeArea("VIC"),
WithPostCode("3000 VIC"), // Invalid post code
WithCountry("AU"),
},
},
{
Address: []func(*Address){
WithName("John Smith"),
WithOrganization("Company Pty Ltd"),
WithStreetAddress([]string{
"525 Collins Street",
}),
WithLocality("Melbourne"),
WithAdministrativeArea("VIC"),
WithPostCode("VIC 3000 VIC"), // Invalid post code
WithCountry("AU"),
},
},
{
Address: []func(*Address){
WithLocality("Melbourne"), // Missing street address
WithAdministrativeArea("VIC"),
WithPostCode("3000"),
WithCountry("AU"),
},
},
{
Address: []func(*Address){
WithStreetAddress([]string{
"525 Collins Street",
}),
WithDependentLocality("Toorak"), // Extraneous field
WithLocality("Melbourne"),
WithAdministrativeArea("VIC"),
WithPostCode("3000"),
WithCountry("AU"),
},
},
{
Address: []func(*Address){
WithStreetAddress([]string{
"No.1 Jianguomenwai Avenue",
}),
WithAdministrativeArea("ASDF"), // Invalid administrative area
WithPostCode("677000"),
WithCountry("CN"),
},
},
{
Address: []func(*Address){
WithStreetAddress([]string{
"No.1 Jianguomenwai Avenue",
}),
WithAdministrativeArea("53"), // Missing locality and dependent locality
WithPostCode("677000"),
WithCountry("CN"),
},
},
{
Address: []func(*Address){
WithStreetAddress([]string{
"No.1 Jianguomenwai Avenue",
}),
WithLocality("ASDF"), // Invalid locality
WithAdministrativeArea("53"),
WithPostCode("677000"),
WithCountry("CN"),
},
},
{
Address: []func(*Address){
WithStreetAddress([]string{
"No.1 Jianguomenwai Avenue",
}),
WithDependentLocality("ASDF"), // Invalid dependent locality
WithLocality("临沧市"),
WithAdministrativeArea("53"),
WithPostCode("677000"),
WithCountry("CN"),
},
},
{
Address: []func(*Address){
WithStreetAddress([]string{
"Jangnyang-ro 17beon-gil",
}),
WithDependentLocality("북구"),
WithLocality("포항시"),
WithAdministrativeArea("47"),
WithPostCode("38100"), // Invalid post code
WithCountry("KR"),
},
},
}
for i, testCase := range tests {
_, err := NewValid(testCase.Address...)
if err == nil {
t.Errorf("Expected an error when creating an address using test case %d, but there was no error", i)
}
}
}
func TestGetCountries(t *testing.T) {
countries := ListCountries("en")
numCountries := len(countries)
expected := len(generated) - 1
if numCountries != expected {
t.Errorf("Number of countries (%d) does not equal expected number of countries (%d)", numCountries, expected)
}
// Check language
for _, country := range countries {
if country.Code == "AU" {
if country.Name != "Australia" {
t.Errorf("Expected English name of Australia to be Australia, got %s", country.Name)
break
}
}
}
countries = ListCountries("zh")
numCountries = len(countries)
expected = len(generated) - 1
if numCountries != expected {
t.Errorf("Number of countries (%d) does not equal expected number of countries (%d)", numCountries, expected)
}
// Check language
for _, country := range countries {
if country.Code == "AU" {
if country.Name != "澳大利亚" {
t.Errorf("Expected Chinese name of Australia to be 澳大利亚, got %s", country.Name)
break
}
}
}
}
func TestGetCountry(t *testing.T) {
country := GetCountry("AU")
expected := CountryData{
Format: "%O%n%N%n%A%n%C %S %Z",
Required: []Field{
AdministrativeArea, Locality, PostCode, StreetAddress,
},
Allowed: []Field{
AdministrativeArea, Locality, Name, Organization, PostCode, StreetAddress,
},
DefaultLanguage: "en",
AdministrativeAreaNameType: State,
LocalityNameType: Suburb,
DependentLocalityNameType: Suburb,
PostCodeNameType: PostalCode,
PostCodeRegex: PostCodeRegexData{
Regex: `^(\d{4})$`,
SubdivisionRegex: map[string]PostCodeRegexData{
"ACT": {
Regex: `^29|2540|260|261[0-8]|02|2620`},
"NSW": {
Regex: `^1|2[0-57-8]|26[2-9]|261[189]|3500|358[56]|3644|3707`},
"NT": {
Regex: `^0[89]`},
"QLD": {
Regex: `^[49]`},
"SA": {
Regex: `^5|0872`},
"TAS": {
Regex: `^7`},
"VIC": {
Regex: `^[38]`},
"WA": {
Regex: `^6|0872`},
},
},
AdministrativeAreas: map[string][]AdministrativeAreaData{
"en": {
{
ID: "ACT",
Name: "Australian Capital Territory",
},
{
ID: "NSW",
Name: "New South Wales",
},
{
ID: "NT",
Name: "Northern Territory",
},
{
ID: "QLD",
Name: "Queensland",
},
{
ID: "SA",
Name: "South Australia",
},
{
ID: "TAS",
Name: "Tasmania",
},
{
ID: "VIC",
Name: "Victoria",
},
{
ID: "WA",
Name: "Western Australia",
},
},
},
}
if !reflect.DeepEqual(country, expected) {
t.Errorf("Country data for AU does not match expected country data")
}
country = GetCountry("AC")
expected = CountryData{
Format: "%N%n%O%n%A%n%C%n%Z",
Required: []Field{
Locality, StreetAddress,
},
Allowed: []Field{
Locality, Name, Organization, PostCode, StreetAddress,
},
DefaultLanguage: "en",
AdministrativeAreaNameType: Province,
LocalityNameType: City,
DependentLocalityNameType: Suburb,
PostCodeNameType: PostalCode,
PostCodeRegex: PostCodeRegexData{
Regex: `^(ASCN 1ZZ)$`,
},
}
if !reflect.DeepEqual(country, expected) {
t.Errorf("Country data for AC does not match expected country data")
}
country = GetCountry("KR")
expected = CountryData{
Format: "%S %C%D%n%A%n%O%n%N%n%Z",
LatinizedFormat: "%N%n%O%n%A%n%D%n%C%n%S%n%Z",
Required: []Field{
AdministrativeArea, Locality, PostCode, StreetAddress,
},
Allowed: []Field{
AdministrativeArea, DependentLocality, Locality, Name, Organization, PostCode, StreetAddress,
},
DefaultLanguage: "ko",
AdministrativeAreaNameType: DoSi,
LocalityNameType: City,
DependentLocalityNameType: District,
PostCodeNameType: PostalCode,
PostCodeRegex: PostCodeRegexData{
Regex: `^(\d{5})$`,
SubdivisionRegex: map[string]PostCodeRegexData{
"11": {
Regex: `^0[1-8]\d{2}`,
SubdivisionRegex: map[string]PostCodeRegexData{
"강남구": {
Regex: `^06[0-3]`},
"강동구": {
Regex: `^05[2-4]`},
"강북구": {
Regex: `^01[0-2]`},
"강서구": {
Regex: `^07[5-8]`},
"관악구": {
Regex: `^08[78]`},
"광진구": {
Regex: `^0(?:49|5[01])`},
"구로구": {
Regex: `^08[23]`},
"금천구": {
Regex: `^08[56]`},
"노원구": {
Regex: `^01[6-9]`},
"도봉구": {
Regex: `^01[34]`},
"동대문구": {
Regex: `^02[4-6]`},
"동작구": {
Regex: `^0(?:69|70)`},
"마포구": {
Regex: `^0(?:39|4[0-2])`},
"서대문구": {
Regex: `^03[67]`},
"서초구": {
Regex: `^06[5-8]`},
"성동구": {
Regex: `^04[78]`},
"성북구": {
Regex: `^02[78]`},
"송파구": {
Regex: `^05[5-8]`},
"양천구": {
Regex: `^0(?:7[89]|8[01])`},
"영등포구": {
Regex: `^07[2-4]`},
"용산구": {
Regex: `^04[34]`},
"은평구": {
Regex: `^03[3-5]`},
"종로구": {
Regex: `^03[01]`},
"중구": {
Regex: `^04[56]|100`},
"중랑구": {
Regex: `^02[0-2]`},
}},
"26": {
Regex: `^4[6-9]\d{2}`,
SubdivisionRegex: map[string]PostCodeRegexData{
"강서구": {
Regex: `^467`},
"금정구": {
Regex: `^46[23]`},
"기장군": {
Regex: `^460`},
"남구": {
Regex: `^48[45]`},
"동구": {
Regex: `^48[78]`},
"동래구": {
Regex: `^47[789]`},
"부산진구": {
Regex: `^47[123]`},
"북구": {
Regex: `^46[56]`},
"사상구": {
Regex: `^4(?:69|70)`},
"사하구": {
Regex: `^49[345]`},
"서구": {
Regex: `^492`},
"수영구": {
Regex: `^48[23]`},
"연제구": {
Regex: `^47[56]`},
"영도구": {
Regex: `^49[01]`},
"중구": {
Regex: `^489`},
"해운대구": {
Regex: `^48[01]`},
}},
"27": {
Regex: `^4[123]\d{2}`,
SubdivisionRegex: map[string]PostCodeRegexData{
"남구": {
Regex: `^42[45]`},
"달서구": {
Regex: `^42[678]`},
"달성군": {
Regex: `^4(?:29|30)`},
"동구": {
Regex: `^41[0-2]`},
"북구": {
Regex: `^41[45]`},
"서구": {
Regex: `^41[78]`},
"수성구": {
Regex: `^42[0-2]`},
"중구": {
Regex: `^419`},
}},
"28": {
Regex: `^2[1-3]\d{2}`,
SubdivisionRegex: map[string]PostCodeRegexData{
"강화군": {
Regex: `^230`},
"계양구": {
Regex: `^21[01]`},
"남구": {
Regex: `^22[12]`},
"남동구": {
Regex: `^21[5-7]`},
"동구": {
Regex: `^225`},
"부평구": {
Regex: `^21[34]`},
"서구": {
Regex: `^22[6-8]`},
"연수구": {
Regex: `^2(?:19|20)`},
"옹진군": {
Regex: `^231`},
"중구": {
Regex: `^22[34]`},
}},
"29": {
Regex: `^6[12]\d{2}`,
SubdivisionRegex: map[string]PostCodeRegexData{
"광산구": {
Regex: `^62[2-4]`},
"남구": {
Regex: `^61[67]`},
"동구": {
Regex: `^61[45]`},
"북구": {
Regex: `^61[0-2]`},
"서구": {
Regex: `^6(?:19|20)`},
}},
"30": {
Regex: `^3[45]\d{2}`,
SubdivisionRegex: map[string]PostCodeRegexData{
"대덕구": {
Regex: `^34[34]`},
"동구": {
Regex: `^34[5-7]`},
"서구": {
Regex: `^35[2-4]`},
"유성구": {
Regex: `^34[0-2]`},
"중구": {
Regex: `^3(?:4[89]|50)`},
}},
"31": {
Regex: `^4[45]\d{2}`,
SubdivisionRegex: map[string]PostCodeRegexData{
"남구": {
Regex: `^44[67]`},
"동구": {
Regex: `^44[01]`},
"북구": {
Regex: `^442`},
"울주군": {
Regex: `^4(?:49|50)`},
"중구": {
Regex: `^44[45]`},
}},
"41": {
Regex: `^1[0-8]\d{2}`,
SubdivisionRegex: map[string]PostCodeRegexData{
"가평군": {
Regex: `^124`},
"고양시": {
Regex: `^10[2-5]`,
SubdivisionRegex: map[string]PostCodeRegexData{
"덕양구": {
Regex: `^10[245]`},
"일산동구": {
Regex: `^10[2-4]`},
"일산서구": {
Regex: `^10[2-4]`},
}},
"과천시": {
Regex: `^138`},
"광명시": {
Regex: `^14[23]`},
"광주시": {
Regex: `^12[78]`},
"구리시": {
Regex: `^119`},
"군포시": {
Regex: `^158`},
"김포시": {
Regex: `^10[01]`},
"남양주시": {
Regex: `^12[0-3]`},
"동두천시": {
Regex: `^113`},
"부천시": {
Regex: `^14[4-7]`,
SubdivisionRegex: map[string]PostCodeRegexData{
"소사구": {
Regex: `^14[67]`},
"오정구": {
Regex: `^14[45]`},
"원미구": {
Regex: `^14[456]`},
}},
"성남시": {
Regex: `^13[1-6]`,
SubdivisionRegex: map[string]PostCodeRegexData{
"분당구": {
Regex: `^13[3-6]`},
"수정구": {
Regex: `^13[1-46]`},
"중원구": {
Regex: `^13[1-4]`},
}},
"수원시": {
Regex: `^16[2-7]`,
SubdivisionRegex: map[string]PostCodeRegexData{
"권선구": {
Regex: `^16[3-6]`},
"영통구": {
Regex: `^16[245-7]`},
"장안구": {
Regex: `^16[2-4]`},
"팔달구": {
Regex: `^16[2-6]`},
}},
"시흥시": {
Regex: `^1(?:49|5[01])`},
"안산시": {
Regex: `^15[2-6]`,
SubdivisionRegex: map[string]PostCodeRegexData{
"단원구": {
Regex: `^15[2-6]`},
"상록구": {
Regex: `^15[2-6]`},
}},
"안성시": {
Regex: `^17[56]`},
"안양시": {
Regex: `^1(?:39|4[01])`,
SubdivisionRegex: map[string]PostCodeRegexData{
"동안구": {
Regex: `^1(?:39|4[01])`},
"만안구": {
Regex: `^1(?:39|40)`},
}},
"양주시": {
Regex: `^11[45]`},
"양평군": {
Regex: `^125`},
"여주시": {
Regex: `^126`},
"연천군": {
Regex: `^110`},
"오산시": {
Regex: `^181`},
"용인시": {
Regex: `^1(?:6[89]|7[01])`,
SubdivisionRegex: map[string]PostCodeRegexData{
"기흥구": {
Regex: `^1(?:6[89]|7[01])`},
"수지구": {
Regex: `^16[89]`},
"처인구": {
Regex: `^1(?:6[89]|7[01])`},
}},
"의왕시": {
Regex: `^16[01]`},
"의정부시": {
Regex: `^11[6-8]`},
"이천시": {
Regex: `^17[34]`},
"파주시": {
Regex: `^10[89]`},
"평택시": {
Regex: `^1(?:7[7-9]|80)`},
"포천시": {
Regex: `^111`},
"하남시": {
Regex: `^1(?:29|30)`},
"화성시": {
Regex: `^18[2-6]`},
}},
"42": {
Regex: `^2[456]\d{2}`,
SubdivisionRegex: map[string]PostCodeRegexData{
"강릉시": {
Regex: `^25[4-6]`},
"고성군": {
Regex: `^247`},
"동해시": {
Regex: `^25[78]`},
"삼척시": {
Regex: `^259`},
"속초시": {
Regex: `^24[89]`},
"양구군": {
Regex: `^245`},
"양양군": {
Regex: `^250`},
"영월군": {
Regex: `^262`},
"원주시": {
Regex: `^26[3-5]`},
"인제군": {
Regex: `^246`},
"정선군": {
Regex: `^261`},
"철원군": {
Regex: `^240`},
"춘천시": {
Regex: `^24[2-4]`},
"태백시": {
Regex: `^260`},
"평창군": {
Regex: `^253`},
"홍천군": {
Regex: `^251`},
"화천군": {
Regex: `^241`},
"횡성군": {
Regex: `^252`},
}},
"43": {
Regex: `^2[789]\d{2}`,
SubdivisionRegex: map[string]PostCodeRegexData{
"괴산군": {
Regex: `^280`},
"단양군": {
Regex: `^270`},
"보은군": {
Regex: `^289`},
"영동군": {
Regex: `^291`},
"옥천군": {
Regex: `^290`},
"음성군": {
Regex: `^27[67]`},
"제천시": {
Regex: `^27[12]`},
"증평군": {
Regex: `^279`},
"진천군": {
Regex: `^278`},
"청주시": {
Regex: `^28[0-9]`,
SubdivisionRegex: map[string]PostCodeRegexData{
"상당구": {
Regex: `^28[1-3578]`},
"서원구": {
Regex: `^28[1-35-8]`},
"청원구": {
Regex: `^28[13-5]`},
"흥덕구": {
Regex: `^28[1-6]`},
}},
"충주시": {
Regex: `^27[3-5]`},
}},
"44": {
Regex: `^3[1-3]\d{2}`,
SubdivisionRegex: map[string]PostCodeRegexData{
"계룡시": {
Regex: `^328`},
"공주시": {
Regex: `^32[56]`},
"금산군": {
Regex: `^327`},
"논산시": {
Regex: `^3(?:29|30)`},
"당진시": {
Regex: `^31[78]`},
"보령시": {
Regex: `^33[45]`},
"부여군": {
Regex: `^33[12]`},
"서산시": {
Regex: `^3(?:19|20)`},
"서천군": {
Regex: `^336`},
"아산시": {
Regex: `^31[45]`},
"예산군": {
Regex: `^324`},
"천안시": {
Regex: `^31[0-2]`,
SubdivisionRegex: map[string]PostCodeRegexData{
"동남구": {
Regex: `^31[0-2]`},
"서북구": {
Regex: `^31[01]`},
}},
"청양군": {
Regex: `^333`},
"태안군": {
Regex: `^321`},
"홍성군": {
Regex: `^322`},
}},
"45": {
Regex: `^5[4-6]\d{2}`,
SubdivisionRegex: map[string]PostCodeRegexData{
"고창군": {
Regex: `^564`},
"군산시": {
Regex: `^54[01]`},
"김제시": {
Regex: `^54[34]`},
"남원시": {
Regex: `^55[78]`},