-
Notifications
You must be signed in to change notification settings - Fork 16
/
constants.go
76 lines (69 loc) · 1.36 KB
/
constants.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
//go:generate stringer -type=Field,FieldName -output=constant_string.go
package address
// Field is an address field type.
type Field int
const (
Country Field = iota + 1
Name
Organization
StreetAddress
DependentLocality
Locality
AdministrativeArea
PostCode
SortingCode
)
// Key returns the corresponding one-letter abbreviation used by Google to refer to address fields.
// This is useful for parsing the address format for a country.
// See https://github.com/googlei18n/libaddressinput/wiki/AddressValidationMetadata for more information.
func (i Field) Key() string {
switch i {
case Country:
return "country"
case Name:
return "N"
case Organization:
return "O"
case StreetAddress:
return "A"
case DependentLocality:
return "D"
case Locality:
return "C"
case AdministrativeArea:
return "S"
case PostCode:
return "Z"
case SortingCode:
return "X"
}
return ""
}
// FieldName is the name to be used when referring to a field.
// For example, in India, the post code is called PIN Code instead of Post Code.
// The field name allows you to display the appropriate form labels to the user.
type FieldName int
const (
Area FieldName = iota + 1
City
County
Department
District
DoSi
Eircode
Emirate
Island
Neighborhood
Oblast
PINCode
Parish
PostTown
PostalCode
Prefecture
Province
State
Suburb
Townland
VillageTownship
ZipCode
)