/
fielded_address.go
184 lines (136 loc) · 4.72 KB
/
fielded_address.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
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// FieldedAddress A type of Address that has a discrete field and value for each type of boundary or identifier down to the lowest level of detail. For example “street number” is one field, “street name” is another field, etc.
//
// swagger:model FieldedAddress
type FieldedAddress struct {
// The city that the address is in
// Required: true
City *string `json:"city"`
// Country that the address is in
// Required: true
Country *string `json:"country"`
// geographic sub address
GeographicSubAddress *GeographicSubAddress `json:"geographicSubAddress,omitempty"`
// id of the fielded address
ID string `json:"id,omitempty"`
// The locality that the address is in
Locality string `json:"locality,omitempty"`
// Descriptor for a postal delivery area, used to speed and simplify the delivery of mail (also known as zipcode)
// Required: true
Postcode *string `json:"postcode"`
// An extension of a postal code. E.g. the part following the dash in an american urban property address
PostcodeExtension string `json:"postcodeExtension,omitempty"`
// The State or Province that the address is in
// Required: true
StateOrProvince *string `json:"stateOrProvince"`
// Name of the street or other street type
StreetName string `json:"streetName,omitempty"`
// Number identifying a specific property on a public street. It may be combined with streetNrLast for ranged addresses
StreetNr string `json:"streetNr,omitempty"`
// Last number in a range of street numbers allocated to a property
StreetNrLast string `json:"streetNrLast,omitempty"`
// Last street number suffix for a ranged address
StreetNrLastSuffix string `json:"streetNrLastSuffix,omitempty"`
// The first street number suffix
StreetNrSuffix string `json:"streetNrSuffix,omitempty"`
// A modifier denoting a relative direction
StreetSuffix string `json:"streetSuffix,omitempty"`
// Alley, avenue, boulevard, brae, crescent, drive, highway, lane, terrace, parade, place, tarn, way, wharf
// Required: true
StreetType *string `json:"streetType"`
}
// Validate validates this fielded address
func (m *FieldedAddress) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCity(formats); err != nil {
res = append(res, err)
}
if err := m.validateCountry(formats); err != nil {
res = append(res, err)
}
if err := m.validateGeographicSubAddress(formats); err != nil {
res = append(res, err)
}
if err := m.validatePostcode(formats); err != nil {
res = append(res, err)
}
if err := m.validateStateOrProvince(formats); err != nil {
res = append(res, err)
}
if err := m.validateStreetType(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *FieldedAddress) validateCity(formats strfmt.Registry) error {
if err := validate.Required("city", "body", m.City); err != nil {
return err
}
return nil
}
func (m *FieldedAddress) validateCountry(formats strfmt.Registry) error {
if err := validate.Required("country", "body", m.Country); err != nil {
return err
}
return nil
}
func (m *FieldedAddress) validateGeographicSubAddress(formats strfmt.Registry) error {
if swag.IsZero(m.GeographicSubAddress) { // not required
return nil
}
if m.GeographicSubAddress != nil {
if err := m.GeographicSubAddress.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("geographicSubAddress")
}
return err
}
}
return nil
}
func (m *FieldedAddress) validatePostcode(formats strfmt.Registry) error {
if err := validate.Required("postcode", "body", m.Postcode); err != nil {
return err
}
return nil
}
func (m *FieldedAddress) validateStateOrProvince(formats strfmt.Registry) error {
if err := validate.Required("stateOrProvince", "body", m.StateOrProvince); err != nil {
return err
}
return nil
}
func (m *FieldedAddress) validateStreetType(formats strfmt.Registry) error {
if err := validate.Required("streetType", "body", m.StreetType); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *FieldedAddress) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *FieldedAddress) UnmarshalBinary(b []byte) error {
var res FieldedAddress
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}