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 "encoding/json"
27
28 "github.com/go-openapi/errors"
29 "github.com/go-openapi/strfmt"
30 "github.com/go-openapi/swag"
31 "github.com/go-openapi/validate"
32 )
33
34
35
36
37
38
39 type CoseV001Schema struct {
40
41
42 Data *CoseV001SchemaData `json:"data,omitempty"`
43
44
45
46 Message strfmt.Base64 `json:"message,omitempty"`
47
48
49
50
51 PublicKey *strfmt.Base64 `json:"publicKey"`
52 }
53
54
55 func (m *CoseV001Schema) Validate(formats strfmt.Registry) error {
56 var res []error
57
58 if err := m.validateData(formats); err != nil {
59 res = append(res, err)
60 }
61
62 if err := m.validatePublicKey(formats); err != nil {
63 res = append(res, err)
64 }
65
66 if len(res) > 0 {
67 return errors.CompositeValidationError(res...)
68 }
69 return nil
70 }
71
72 func (m *CoseV001Schema) validateData(formats strfmt.Registry) error {
73 if swag.IsZero(m.Data) {
74 return nil
75 }
76
77 if m.Data != nil {
78 if err := m.Data.Validate(formats); err != nil {
79 if ve, ok := err.(*errors.Validation); ok {
80 return ve.ValidateName("data")
81 } else if ce, ok := err.(*errors.CompositeError); ok {
82 return ce.ValidateName("data")
83 }
84 return err
85 }
86 }
87
88 return nil
89 }
90
91 func (m *CoseV001Schema) validatePublicKey(formats strfmt.Registry) error {
92
93 if err := validate.Required("publicKey", "body", m.PublicKey); err != nil {
94 return err
95 }
96
97 return nil
98 }
99
100
101 func (m *CoseV001Schema) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
102 var res []error
103
104 if err := m.contextValidateData(ctx, formats); err != nil {
105 res = append(res, err)
106 }
107
108 if len(res) > 0 {
109 return errors.CompositeValidationError(res...)
110 }
111 return nil
112 }
113
114 func (m *CoseV001Schema) contextValidateData(ctx context.Context, formats strfmt.Registry) error {
115
116 if m.Data != nil {
117
118 if swag.IsZero(m.Data) {
119 return nil
120 }
121
122 if err := m.Data.ContextValidate(ctx, formats); err != nil {
123 if ve, ok := err.(*errors.Validation); ok {
124 return ve.ValidateName("data")
125 } else if ce, ok := err.(*errors.CompositeError); ok {
126 return ce.ValidateName("data")
127 }
128 return err
129 }
130 }
131
132 return nil
133 }
134
135
136 func (m *CoseV001Schema) MarshalBinary() ([]byte, error) {
137 if m == nil {
138 return nil, nil
139 }
140 return swag.WriteJSON(m)
141 }
142
143
144 func (m *CoseV001Schema) UnmarshalBinary(b []byte) error {
145 var res CoseV001Schema
146 if err := swag.ReadJSON(b, &res); err != nil {
147 return err
148 }
149 *m = res
150 return nil
151 }
152
153
154
155
156 type CoseV001SchemaData struct {
157
158
159
160 Aad strfmt.Base64 `json:"aad,omitempty"`
161
162
163 EnvelopeHash *CoseV001SchemaDataEnvelopeHash `json:"envelopeHash,omitempty"`
164
165
166 PayloadHash *CoseV001SchemaDataPayloadHash `json:"payloadHash,omitempty"`
167 }
168
169
170 func (m *CoseV001SchemaData) Validate(formats strfmt.Registry) error {
171 var res []error
172
173 if err := m.validateEnvelopeHash(formats); err != nil {
174 res = append(res, err)
175 }
176
177 if err := m.validatePayloadHash(formats); err != nil {
178 res = append(res, err)
179 }
180
181 if len(res) > 0 {
182 return errors.CompositeValidationError(res...)
183 }
184 return nil
185 }
186
187 func (m *CoseV001SchemaData) validateEnvelopeHash(formats strfmt.Registry) error {
188 if swag.IsZero(m.EnvelopeHash) {
189 return nil
190 }
191
192 if m.EnvelopeHash != nil {
193 if err := m.EnvelopeHash.Validate(formats); err != nil {
194 if ve, ok := err.(*errors.Validation); ok {
195 return ve.ValidateName("data" + "." + "envelopeHash")
196 } else if ce, ok := err.(*errors.CompositeError); ok {
197 return ce.ValidateName("data" + "." + "envelopeHash")
198 }
199 return err
200 }
201 }
202
203 return nil
204 }
205
206 func (m *CoseV001SchemaData) validatePayloadHash(formats strfmt.Registry) error {
207 if swag.IsZero(m.PayloadHash) {
208 return nil
209 }
210
211 if m.PayloadHash != nil {
212 if err := m.PayloadHash.Validate(formats); err != nil {
213 if ve, ok := err.(*errors.Validation); ok {
214 return ve.ValidateName("data" + "." + "payloadHash")
215 } else if ce, ok := err.(*errors.CompositeError); ok {
216 return ce.ValidateName("data" + "." + "payloadHash")
217 }
218 return err
219 }
220 }
221
222 return nil
223 }
224
225
226 func (m *CoseV001SchemaData) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
227 var res []error
228
229 if err := m.contextValidateEnvelopeHash(ctx, formats); err != nil {
230 res = append(res, err)
231 }
232
233 if err := m.contextValidatePayloadHash(ctx, formats); err != nil {
234 res = append(res, err)
235 }
236
237 if len(res) > 0 {
238 return errors.CompositeValidationError(res...)
239 }
240 return nil
241 }
242
243 func (m *CoseV001SchemaData) contextValidateEnvelopeHash(ctx context.Context, formats strfmt.Registry) error {
244
245 if m.EnvelopeHash != nil {
246
247 if swag.IsZero(m.EnvelopeHash) {
248 return nil
249 }
250
251 if err := m.EnvelopeHash.ContextValidate(ctx, formats); err != nil {
252 if ve, ok := err.(*errors.Validation); ok {
253 return ve.ValidateName("data" + "." + "envelopeHash")
254 } else if ce, ok := err.(*errors.CompositeError); ok {
255 return ce.ValidateName("data" + "." + "envelopeHash")
256 }
257 return err
258 }
259 }
260
261 return nil
262 }
263
264 func (m *CoseV001SchemaData) contextValidatePayloadHash(ctx context.Context, formats strfmt.Registry) error {
265
266 if m.PayloadHash != nil {
267
268 if swag.IsZero(m.PayloadHash) {
269 return nil
270 }
271
272 if err := m.PayloadHash.ContextValidate(ctx, formats); err != nil {
273 if ve, ok := err.(*errors.Validation); ok {
274 return ve.ValidateName("data" + "." + "payloadHash")
275 } else if ce, ok := err.(*errors.CompositeError); ok {
276 return ce.ValidateName("data" + "." + "payloadHash")
277 }
278 return err
279 }
280 }
281
282 return nil
283 }
284
285
286 func (m *CoseV001SchemaData) MarshalBinary() ([]byte, error) {
287 if m == nil {
288 return nil, nil
289 }
290 return swag.WriteJSON(m)
291 }
292
293
294 func (m *CoseV001SchemaData) UnmarshalBinary(b []byte) error {
295 var res CoseV001SchemaData
296 if err := swag.ReadJSON(b, &res); err != nil {
297 return err
298 }
299 *m = res
300 return nil
301 }
302
303
304
305
306 type CoseV001SchemaDataEnvelopeHash struct {
307
308
309
310
311 Algorithm *string `json:"algorithm"`
312
313
314
315 Value *string `json:"value"`
316 }
317
318
319 func (m *CoseV001SchemaDataEnvelopeHash) Validate(formats strfmt.Registry) error {
320 var res []error
321
322 if err := m.validateAlgorithm(formats); err != nil {
323 res = append(res, err)
324 }
325
326 if err := m.validateValue(formats); err != nil {
327 res = append(res, err)
328 }
329
330 if len(res) > 0 {
331 return errors.CompositeValidationError(res...)
332 }
333 return nil
334 }
335
336 var coseV001SchemaDataEnvelopeHashTypeAlgorithmPropEnum []interface{}
337
338 func init() {
339 var res []string
340 if err := json.Unmarshal([]byte(`["sha256"]`), &res); err != nil {
341 panic(err)
342 }
343 for _, v := range res {
344 coseV001SchemaDataEnvelopeHashTypeAlgorithmPropEnum = append(coseV001SchemaDataEnvelopeHashTypeAlgorithmPropEnum, v)
345 }
346 }
347
348 const (
349
350
351 CoseV001SchemaDataEnvelopeHashAlgorithmSha256 string = "sha256"
352 )
353
354
355 func (m *CoseV001SchemaDataEnvelopeHash) validateAlgorithmEnum(path, location string, value string) error {
356 if err := validate.EnumCase(path, location, value, coseV001SchemaDataEnvelopeHashTypeAlgorithmPropEnum, true); err != nil {
357 return err
358 }
359 return nil
360 }
361
362 func (m *CoseV001SchemaDataEnvelopeHash) validateAlgorithm(formats strfmt.Registry) error {
363
364 if err := validate.Required("data"+"."+"envelopeHash"+"."+"algorithm", "body", m.Algorithm); err != nil {
365 return err
366 }
367
368
369 if err := m.validateAlgorithmEnum("data"+"."+"envelopeHash"+"."+"algorithm", "body", *m.Algorithm); err != nil {
370 return err
371 }
372
373 return nil
374 }
375
376 func (m *CoseV001SchemaDataEnvelopeHash) validateValue(formats strfmt.Registry) error {
377
378 if err := validate.Required("data"+"."+"envelopeHash"+"."+"value", "body", m.Value); err != nil {
379 return err
380 }
381
382 return nil
383 }
384
385
386 func (m *CoseV001SchemaDataEnvelopeHash) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
387 var res []error
388
389 if len(res) > 0 {
390 return errors.CompositeValidationError(res...)
391 }
392 return nil
393 }
394
395
396 func (m *CoseV001SchemaDataEnvelopeHash) MarshalBinary() ([]byte, error) {
397 if m == nil {
398 return nil, nil
399 }
400 return swag.WriteJSON(m)
401 }
402
403
404 func (m *CoseV001SchemaDataEnvelopeHash) UnmarshalBinary(b []byte) error {
405 var res CoseV001SchemaDataEnvelopeHash
406 if err := swag.ReadJSON(b, &res); err != nil {
407 return err
408 }
409 *m = res
410 return nil
411 }
412
413
414
415
416 type CoseV001SchemaDataPayloadHash struct {
417
418
419
420
421 Algorithm *string `json:"algorithm"`
422
423
424
425 Value *string `json:"value"`
426 }
427
428
429 func (m *CoseV001SchemaDataPayloadHash) Validate(formats strfmt.Registry) error {
430 var res []error
431
432 if err := m.validateAlgorithm(formats); err != nil {
433 res = append(res, err)
434 }
435
436 if err := m.validateValue(formats); err != nil {
437 res = append(res, err)
438 }
439
440 if len(res) > 0 {
441 return errors.CompositeValidationError(res...)
442 }
443 return nil
444 }
445
446 var coseV001SchemaDataPayloadHashTypeAlgorithmPropEnum []interface{}
447
448 func init() {
449 var res []string
450 if err := json.Unmarshal([]byte(`["sha256"]`), &res); err != nil {
451 panic(err)
452 }
453 for _, v := range res {
454 coseV001SchemaDataPayloadHashTypeAlgorithmPropEnum = append(coseV001SchemaDataPayloadHashTypeAlgorithmPropEnum, v)
455 }
456 }
457
458 const (
459
460
461 CoseV001SchemaDataPayloadHashAlgorithmSha256 string = "sha256"
462 )
463
464
465 func (m *CoseV001SchemaDataPayloadHash) validateAlgorithmEnum(path, location string, value string) error {
466 if err := validate.EnumCase(path, location, value, coseV001SchemaDataPayloadHashTypeAlgorithmPropEnum, true); err != nil {
467 return err
468 }
469 return nil
470 }
471
472 func (m *CoseV001SchemaDataPayloadHash) validateAlgorithm(formats strfmt.Registry) error {
473
474 if err := validate.Required("data"+"."+"payloadHash"+"."+"algorithm", "body", m.Algorithm); err != nil {
475 return err
476 }
477
478
479 if err := m.validateAlgorithmEnum("data"+"."+"payloadHash"+"."+"algorithm", "body", *m.Algorithm); err != nil {
480 return err
481 }
482
483 return nil
484 }
485
486 func (m *CoseV001SchemaDataPayloadHash) validateValue(formats strfmt.Registry) error {
487
488 if err := validate.Required("data"+"."+"payloadHash"+"."+"value", "body", m.Value); err != nil {
489 return err
490 }
491
492 return nil
493 }
494
495
496 func (m *CoseV001SchemaDataPayloadHash) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
497 var res []error
498
499 if len(res) > 0 {
500 return errors.CompositeValidationError(res...)
501 }
502 return nil
503 }
504
505
506 func (m *CoseV001SchemaDataPayloadHash) MarshalBinary() ([]byte, error) {
507 if m == nil {
508 return nil, nil
509 }
510 return swag.WriteJSON(m)
511 }
512
513
514 func (m *CoseV001SchemaDataPayloadHash) UnmarshalBinary(b []byte) error {
515 var res CoseV001SchemaDataPayloadHash
516 if err := swag.ReadJSON(b, &res); err != nil {
517 return err
518 }
519 *m = res
520 return nil
521 }
522
View as plain text