1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package models
20
21
22
23
24 import (
25 "context"
26
27 "github.com/go-openapi/errors"
28 "github.com/go-openapi/strfmt"
29 "github.com/go-openapi/swag"
30 "github.com/go-openapi/validate"
31 )
32
33
34
35
36
37
38 type TUFV001Schema struct {
39
40
41
42 Metadata *TUFV001SchemaMetadata `json:"metadata"`
43
44
45
46 Root *TUFV001SchemaRoot `json:"root"`
47
48
49
50 SpecVersion string `json:"spec_version,omitempty"`
51 }
52
53
54 func (m *TUFV001Schema) Validate(formats strfmt.Registry) error {
55 var res []error
56
57 if err := m.validateMetadata(formats); err != nil {
58 res = append(res, err)
59 }
60
61 if err := m.validateRoot(formats); err != nil {
62 res = append(res, err)
63 }
64
65 if len(res) > 0 {
66 return errors.CompositeValidationError(res...)
67 }
68 return nil
69 }
70
71 func (m *TUFV001Schema) validateMetadata(formats strfmt.Registry) error {
72
73 if err := validate.Required("metadata", "body", m.Metadata); err != nil {
74 return err
75 }
76
77 if m.Metadata != nil {
78 if err := m.Metadata.Validate(formats); err != nil {
79 if ve, ok := err.(*errors.Validation); ok {
80 return ve.ValidateName("metadata")
81 } else if ce, ok := err.(*errors.CompositeError); ok {
82 return ce.ValidateName("metadata")
83 }
84 return err
85 }
86 }
87
88 return nil
89 }
90
91 func (m *TUFV001Schema) validateRoot(formats strfmt.Registry) error {
92
93 if err := validate.Required("root", "body", m.Root); err != nil {
94 return err
95 }
96
97 if m.Root != nil {
98 if err := m.Root.Validate(formats); err != nil {
99 if ve, ok := err.(*errors.Validation); ok {
100 return ve.ValidateName("root")
101 } else if ce, ok := err.(*errors.CompositeError); ok {
102 return ce.ValidateName("root")
103 }
104 return err
105 }
106 }
107
108 return nil
109 }
110
111
112 func (m *TUFV001Schema) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
113 var res []error
114
115 if err := m.contextValidateMetadata(ctx, formats); err != nil {
116 res = append(res, err)
117 }
118
119 if err := m.contextValidateRoot(ctx, formats); err != nil {
120 res = append(res, err)
121 }
122
123 if err := m.contextValidateSpecVersion(ctx, formats); err != nil {
124 res = append(res, err)
125 }
126
127 if len(res) > 0 {
128 return errors.CompositeValidationError(res...)
129 }
130 return nil
131 }
132
133 func (m *TUFV001Schema) contextValidateMetadata(ctx context.Context, formats strfmt.Registry) error {
134
135 if m.Metadata != nil {
136
137 if err := m.Metadata.ContextValidate(ctx, formats); err != nil {
138 if ve, ok := err.(*errors.Validation); ok {
139 return ve.ValidateName("metadata")
140 } else if ce, ok := err.(*errors.CompositeError); ok {
141 return ce.ValidateName("metadata")
142 }
143 return err
144 }
145 }
146
147 return nil
148 }
149
150 func (m *TUFV001Schema) contextValidateRoot(ctx context.Context, formats strfmt.Registry) error {
151
152 if m.Root != nil {
153
154 if err := m.Root.ContextValidate(ctx, formats); err != nil {
155 if ve, ok := err.(*errors.Validation); ok {
156 return ve.ValidateName("root")
157 } else if ce, ok := err.(*errors.CompositeError); ok {
158 return ce.ValidateName("root")
159 }
160 return err
161 }
162 }
163
164 return nil
165 }
166
167 func (m *TUFV001Schema) contextValidateSpecVersion(ctx context.Context, formats strfmt.Registry) error {
168
169 if err := validate.ReadOnly(ctx, "spec_version", "body", string(m.SpecVersion)); err != nil {
170 return err
171 }
172
173 return nil
174 }
175
176
177 func (m *TUFV001Schema) MarshalBinary() ([]byte, error) {
178 if m == nil {
179 return nil, nil
180 }
181 return swag.WriteJSON(m)
182 }
183
184
185 func (m *TUFV001Schema) UnmarshalBinary(b []byte) error {
186 var res TUFV001Schema
187 if err := swag.ReadJSON(b, &res); err != nil {
188 return err
189 }
190 *m = res
191 return nil
192 }
193
194
195
196
197 type TUFV001SchemaMetadata struct {
198
199
200
201 Content interface{} `json:"content"`
202 }
203
204
205 func (m *TUFV001SchemaMetadata) Validate(formats strfmt.Registry) error {
206 var res []error
207
208 if err := m.validateContent(formats); err != nil {
209 res = append(res, err)
210 }
211
212 if len(res) > 0 {
213 return errors.CompositeValidationError(res...)
214 }
215 return nil
216 }
217
218 func (m *TUFV001SchemaMetadata) validateContent(formats strfmt.Registry) error {
219
220 if m.Content == nil {
221 return errors.Required("metadata"+"."+"content", "body", nil)
222 }
223
224 return nil
225 }
226
227
228 func (m *TUFV001SchemaMetadata) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
229 return nil
230 }
231
232
233 func (m *TUFV001SchemaMetadata) MarshalBinary() ([]byte, error) {
234 if m == nil {
235 return nil, nil
236 }
237 return swag.WriteJSON(m)
238 }
239
240
241 func (m *TUFV001SchemaMetadata) UnmarshalBinary(b []byte) error {
242 var res TUFV001SchemaMetadata
243 if err := swag.ReadJSON(b, &res); err != nil {
244 return err
245 }
246 *m = res
247 return nil
248 }
249
250
251
252
253 type TUFV001SchemaRoot struct {
254
255
256
257 Content interface{} `json:"content"`
258 }
259
260
261 func (m *TUFV001SchemaRoot) Validate(formats strfmt.Registry) error {
262 var res []error
263
264 if err := m.validateContent(formats); err != nil {
265 res = append(res, err)
266 }
267
268 if len(res) > 0 {
269 return errors.CompositeValidationError(res...)
270 }
271 return nil
272 }
273
274 func (m *TUFV001SchemaRoot) validateContent(formats strfmt.Registry) error {
275
276 if m.Content == nil {
277 return errors.Required("root"+"."+"content", "body", nil)
278 }
279
280 return nil
281 }
282
283
284 func (m *TUFV001SchemaRoot) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
285 return nil
286 }
287
288
289 func (m *TUFV001SchemaRoot) MarshalBinary() ([]byte, error) {
290 if m == nil {
291 return nil, nil
292 }
293 return swag.WriteJSON(m)
294 }
295
296
297 func (m *TUFV001SchemaRoot) UnmarshalBinary(b []byte) error {
298 var res TUFV001SchemaRoot
299 if err := swag.ReadJSON(b, &res); err != nil {
300 return err
301 }
302 *m = res
303 return nil
304 }
305
View as plain text