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 "strconv"
28
29 "github.com/go-openapi/errors"
30 "github.com/go-openapi/strfmt"
31 "github.com/go-openapi/swag"
32 "github.com/go-openapi/validate"
33 )
34
35
36
37
38
39
40 type DSSEV001Schema struct {
41
42
43 EnvelopeHash *DSSEV001SchemaEnvelopeHash `json:"envelopeHash,omitempty"`
44
45
46 PayloadHash *DSSEV001SchemaPayloadHash `json:"payloadHash,omitempty"`
47
48
49 ProposedContent *DSSEV001SchemaProposedContent `json:"proposedContent,omitempty"`
50
51
52
53
54 Signatures []*DSSEV001SchemaSignaturesItems0 `json:"signatures"`
55 }
56
57
58 func (m *DSSEV001Schema) Validate(formats strfmt.Registry) error {
59 var res []error
60
61 if err := m.validateEnvelopeHash(formats); err != nil {
62 res = append(res, err)
63 }
64
65 if err := m.validatePayloadHash(formats); err != nil {
66 res = append(res, err)
67 }
68
69 if err := m.validateProposedContent(formats); err != nil {
70 res = append(res, err)
71 }
72
73 if err := m.validateSignatures(formats); err != nil {
74 res = append(res, err)
75 }
76
77 if len(res) > 0 {
78 return errors.CompositeValidationError(res...)
79 }
80 return nil
81 }
82
83 func (m *DSSEV001Schema) validateEnvelopeHash(formats strfmt.Registry) error {
84 if swag.IsZero(m.EnvelopeHash) {
85 return nil
86 }
87
88 if m.EnvelopeHash != nil {
89 if err := m.EnvelopeHash.Validate(formats); err != nil {
90 if ve, ok := err.(*errors.Validation); ok {
91 return ve.ValidateName("envelopeHash")
92 } else if ce, ok := err.(*errors.CompositeError); ok {
93 return ce.ValidateName("envelopeHash")
94 }
95 return err
96 }
97 }
98
99 return nil
100 }
101
102 func (m *DSSEV001Schema) validatePayloadHash(formats strfmt.Registry) error {
103 if swag.IsZero(m.PayloadHash) {
104 return nil
105 }
106
107 if m.PayloadHash != nil {
108 if err := m.PayloadHash.Validate(formats); err != nil {
109 if ve, ok := err.(*errors.Validation); ok {
110 return ve.ValidateName("payloadHash")
111 } else if ce, ok := err.(*errors.CompositeError); ok {
112 return ce.ValidateName("payloadHash")
113 }
114 return err
115 }
116 }
117
118 return nil
119 }
120
121 func (m *DSSEV001Schema) validateProposedContent(formats strfmt.Registry) error {
122 if swag.IsZero(m.ProposedContent) {
123 return nil
124 }
125
126 if m.ProposedContent != nil {
127 if err := m.ProposedContent.Validate(formats); err != nil {
128 if ve, ok := err.(*errors.Validation); ok {
129 return ve.ValidateName("proposedContent")
130 } else if ce, ok := err.(*errors.CompositeError); ok {
131 return ce.ValidateName("proposedContent")
132 }
133 return err
134 }
135 }
136
137 return nil
138 }
139
140 func (m *DSSEV001Schema) validateSignatures(formats strfmt.Registry) error {
141 if swag.IsZero(m.Signatures) {
142 return nil
143 }
144
145 iSignaturesSize := int64(len(m.Signatures))
146
147 if err := validate.MinItems("signatures", "body", iSignaturesSize, 1); err != nil {
148 return err
149 }
150
151 for i := 0; i < len(m.Signatures); i++ {
152 if swag.IsZero(m.Signatures[i]) {
153 continue
154 }
155
156 if m.Signatures[i] != nil {
157 if err := m.Signatures[i].Validate(formats); err != nil {
158 if ve, ok := err.(*errors.Validation); ok {
159 return ve.ValidateName("signatures" + "." + strconv.Itoa(i))
160 } else if ce, ok := err.(*errors.CompositeError); ok {
161 return ce.ValidateName("signatures" + "." + strconv.Itoa(i))
162 }
163 return err
164 }
165 }
166
167 }
168
169 return nil
170 }
171
172
173 func (m *DSSEV001Schema) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
174 var res []error
175
176 if err := m.contextValidateEnvelopeHash(ctx, formats); err != nil {
177 res = append(res, err)
178 }
179
180 if err := m.contextValidatePayloadHash(ctx, formats); err != nil {
181 res = append(res, err)
182 }
183
184 if err := m.contextValidateProposedContent(ctx, formats); err != nil {
185 res = append(res, err)
186 }
187
188 if err := m.contextValidateSignatures(ctx, formats); err != nil {
189 res = append(res, err)
190 }
191
192 if len(res) > 0 {
193 return errors.CompositeValidationError(res...)
194 }
195 return nil
196 }
197
198 func (m *DSSEV001Schema) contextValidateEnvelopeHash(ctx context.Context, formats strfmt.Registry) error {
199
200 if m.EnvelopeHash != nil {
201
202 if swag.IsZero(m.EnvelopeHash) {
203 return nil
204 }
205
206 if err := m.EnvelopeHash.ContextValidate(ctx, formats); err != nil {
207 if ve, ok := err.(*errors.Validation); ok {
208 return ve.ValidateName("envelopeHash")
209 } else if ce, ok := err.(*errors.CompositeError); ok {
210 return ce.ValidateName("envelopeHash")
211 }
212 return err
213 }
214 }
215
216 return nil
217 }
218
219 func (m *DSSEV001Schema) contextValidatePayloadHash(ctx context.Context, formats strfmt.Registry) error {
220
221 if m.PayloadHash != nil {
222
223 if swag.IsZero(m.PayloadHash) {
224 return nil
225 }
226
227 if err := m.PayloadHash.ContextValidate(ctx, formats); err != nil {
228 if ve, ok := err.(*errors.Validation); ok {
229 return ve.ValidateName("payloadHash")
230 } else if ce, ok := err.(*errors.CompositeError); ok {
231 return ce.ValidateName("payloadHash")
232 }
233 return err
234 }
235 }
236
237 return nil
238 }
239
240 func (m *DSSEV001Schema) contextValidateProposedContent(ctx context.Context, formats strfmt.Registry) error {
241
242 if m.ProposedContent != nil {
243
244 if swag.IsZero(m.ProposedContent) {
245 return nil
246 }
247
248 if err := m.ProposedContent.ContextValidate(ctx, formats); err != nil {
249 if ve, ok := err.(*errors.Validation); ok {
250 return ve.ValidateName("proposedContent")
251 } else if ce, ok := err.(*errors.CompositeError); ok {
252 return ce.ValidateName("proposedContent")
253 }
254 return err
255 }
256 }
257
258 return nil
259 }
260
261 func (m *DSSEV001Schema) contextValidateSignatures(ctx context.Context, formats strfmt.Registry) error {
262
263 if err := validate.ReadOnly(ctx, "signatures", "body", []*DSSEV001SchemaSignaturesItems0(m.Signatures)); err != nil {
264 return err
265 }
266
267 for i := 0; i < len(m.Signatures); i++ {
268
269 if m.Signatures[i] != nil {
270
271 if swag.IsZero(m.Signatures[i]) {
272 return nil
273 }
274
275 if err := m.Signatures[i].ContextValidate(ctx, formats); err != nil {
276 if ve, ok := err.(*errors.Validation); ok {
277 return ve.ValidateName("signatures" + "." + strconv.Itoa(i))
278 } else if ce, ok := err.(*errors.CompositeError); ok {
279 return ce.ValidateName("signatures" + "." + strconv.Itoa(i))
280 }
281 return err
282 }
283 }
284
285 }
286
287 return nil
288 }
289
290
291 func (m *DSSEV001Schema) MarshalBinary() ([]byte, error) {
292 if m == nil {
293 return nil, nil
294 }
295 return swag.WriteJSON(m)
296 }
297
298
299 func (m *DSSEV001Schema) UnmarshalBinary(b []byte) error {
300 var res DSSEV001Schema
301 if err := swag.ReadJSON(b, &res); err != nil {
302 return err
303 }
304 *m = res
305 return nil
306 }
307
308
309
310
311 type DSSEV001SchemaEnvelopeHash struct {
312
313
314
315
316 Algorithm *string `json:"algorithm"`
317
318
319
320 Value *string `json:"value"`
321 }
322
323
324 func (m *DSSEV001SchemaEnvelopeHash) Validate(formats strfmt.Registry) error {
325 var res []error
326
327 if err := m.validateAlgorithm(formats); err != nil {
328 res = append(res, err)
329 }
330
331 if err := m.validateValue(formats); err != nil {
332 res = append(res, err)
333 }
334
335 if len(res) > 0 {
336 return errors.CompositeValidationError(res...)
337 }
338 return nil
339 }
340
341 var dsseV001SchemaEnvelopeHashTypeAlgorithmPropEnum []interface{}
342
343 func init() {
344 var res []string
345 if err := json.Unmarshal([]byte(`["sha256"]`), &res); err != nil {
346 panic(err)
347 }
348 for _, v := range res {
349 dsseV001SchemaEnvelopeHashTypeAlgorithmPropEnum = append(dsseV001SchemaEnvelopeHashTypeAlgorithmPropEnum, v)
350 }
351 }
352
353 const (
354
355
356 DSSEV001SchemaEnvelopeHashAlgorithmSha256 string = "sha256"
357 )
358
359
360 func (m *DSSEV001SchemaEnvelopeHash) validateAlgorithmEnum(path, location string, value string) error {
361 if err := validate.EnumCase(path, location, value, dsseV001SchemaEnvelopeHashTypeAlgorithmPropEnum, true); err != nil {
362 return err
363 }
364 return nil
365 }
366
367 func (m *DSSEV001SchemaEnvelopeHash) validateAlgorithm(formats strfmt.Registry) error {
368
369 if err := validate.Required("envelopeHash"+"."+"algorithm", "body", m.Algorithm); err != nil {
370 return err
371 }
372
373
374 if err := m.validateAlgorithmEnum("envelopeHash"+"."+"algorithm", "body", *m.Algorithm); err != nil {
375 return err
376 }
377
378 return nil
379 }
380
381 func (m *DSSEV001SchemaEnvelopeHash) validateValue(formats strfmt.Registry) error {
382
383 if err := validate.Required("envelopeHash"+"."+"value", "body", m.Value); err != nil {
384 return err
385 }
386
387 return nil
388 }
389
390
391 func (m *DSSEV001SchemaEnvelopeHash) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
392 var res []error
393
394 if len(res) > 0 {
395 return errors.CompositeValidationError(res...)
396 }
397 return nil
398 }
399
400
401 func (m *DSSEV001SchemaEnvelopeHash) MarshalBinary() ([]byte, error) {
402 if m == nil {
403 return nil, nil
404 }
405 return swag.WriteJSON(m)
406 }
407
408
409 func (m *DSSEV001SchemaEnvelopeHash) UnmarshalBinary(b []byte) error {
410 var res DSSEV001SchemaEnvelopeHash
411 if err := swag.ReadJSON(b, &res); err != nil {
412 return err
413 }
414 *m = res
415 return nil
416 }
417
418
419
420
421 type DSSEV001SchemaPayloadHash struct {
422
423
424
425
426 Algorithm *string `json:"algorithm"`
427
428
429
430 Value *string `json:"value"`
431 }
432
433
434 func (m *DSSEV001SchemaPayloadHash) Validate(formats strfmt.Registry) error {
435 var res []error
436
437 if err := m.validateAlgorithm(formats); err != nil {
438 res = append(res, err)
439 }
440
441 if err := m.validateValue(formats); err != nil {
442 res = append(res, err)
443 }
444
445 if len(res) > 0 {
446 return errors.CompositeValidationError(res...)
447 }
448 return nil
449 }
450
451 var dsseV001SchemaPayloadHashTypeAlgorithmPropEnum []interface{}
452
453 func init() {
454 var res []string
455 if err := json.Unmarshal([]byte(`["sha256"]`), &res); err != nil {
456 panic(err)
457 }
458 for _, v := range res {
459 dsseV001SchemaPayloadHashTypeAlgorithmPropEnum = append(dsseV001SchemaPayloadHashTypeAlgorithmPropEnum, v)
460 }
461 }
462
463 const (
464
465
466 DSSEV001SchemaPayloadHashAlgorithmSha256 string = "sha256"
467 )
468
469
470 func (m *DSSEV001SchemaPayloadHash) validateAlgorithmEnum(path, location string, value string) error {
471 if err := validate.EnumCase(path, location, value, dsseV001SchemaPayloadHashTypeAlgorithmPropEnum, true); err != nil {
472 return err
473 }
474 return nil
475 }
476
477 func (m *DSSEV001SchemaPayloadHash) validateAlgorithm(formats strfmt.Registry) error {
478
479 if err := validate.Required("payloadHash"+"."+"algorithm", "body", m.Algorithm); err != nil {
480 return err
481 }
482
483
484 if err := m.validateAlgorithmEnum("payloadHash"+"."+"algorithm", "body", *m.Algorithm); err != nil {
485 return err
486 }
487
488 return nil
489 }
490
491 func (m *DSSEV001SchemaPayloadHash) validateValue(formats strfmt.Registry) error {
492
493 if err := validate.Required("payloadHash"+"."+"value", "body", m.Value); err != nil {
494 return err
495 }
496
497 return nil
498 }
499
500
501 func (m *DSSEV001SchemaPayloadHash) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
502 var res []error
503
504 if len(res) > 0 {
505 return errors.CompositeValidationError(res...)
506 }
507 return nil
508 }
509
510
511 func (m *DSSEV001SchemaPayloadHash) MarshalBinary() ([]byte, error) {
512 if m == nil {
513 return nil, nil
514 }
515 return swag.WriteJSON(m)
516 }
517
518
519 func (m *DSSEV001SchemaPayloadHash) UnmarshalBinary(b []byte) error {
520 var res DSSEV001SchemaPayloadHash
521 if err := swag.ReadJSON(b, &res); err != nil {
522 return err
523 }
524 *m = res
525 return nil
526 }
527
528
529
530
531 type DSSEV001SchemaProposedContent struct {
532
533
534
535 Envelope *string `json:"envelope"`
536
537
538
539
540 Verifiers []strfmt.Base64 `json:"verifiers"`
541 }
542
543
544 func (m *DSSEV001SchemaProposedContent) Validate(formats strfmt.Registry) error {
545 var res []error
546
547 if err := m.validateEnvelope(formats); err != nil {
548 res = append(res, err)
549 }
550
551 if err := m.validateVerifiers(formats); err != nil {
552 res = append(res, err)
553 }
554
555 if len(res) > 0 {
556 return errors.CompositeValidationError(res...)
557 }
558 return nil
559 }
560
561 func (m *DSSEV001SchemaProposedContent) validateEnvelope(formats strfmt.Registry) error {
562
563 if err := validate.Required("proposedContent"+"."+"envelope", "body", m.Envelope); err != nil {
564 return err
565 }
566
567 return nil
568 }
569
570 func (m *DSSEV001SchemaProposedContent) validateVerifiers(formats strfmt.Registry) error {
571
572 if err := validate.Required("proposedContent"+"."+"verifiers", "body", m.Verifiers); err != nil {
573 return err
574 }
575
576 iVerifiersSize := int64(len(m.Verifiers))
577
578 if err := validate.MinItems("proposedContent"+"."+"verifiers", "body", iVerifiersSize, 1); err != nil {
579 return err
580 }
581
582 return nil
583 }
584
585
586 func (m *DSSEV001SchemaProposedContent) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
587 return nil
588 }
589
590
591 func (m *DSSEV001SchemaProposedContent) MarshalBinary() ([]byte, error) {
592 if m == nil {
593 return nil, nil
594 }
595 return swag.WriteJSON(m)
596 }
597
598
599 func (m *DSSEV001SchemaProposedContent) UnmarshalBinary(b []byte) error {
600 var res DSSEV001SchemaProposedContent
601 if err := swag.ReadJSON(b, &res); err != nil {
602 return err
603 }
604 *m = res
605 return nil
606 }
607
608
609
610
611 type DSSEV001SchemaSignaturesItems0 struct {
612
613
614
615
616 Signature *string `json:"signature"`
617
618
619
620
621 Verifier *strfmt.Base64 `json:"verifier"`
622 }
623
624
625 func (m *DSSEV001SchemaSignaturesItems0) Validate(formats strfmt.Registry) error {
626 var res []error
627
628 if err := m.validateSignature(formats); err != nil {
629 res = append(res, err)
630 }
631
632 if err := m.validateVerifier(formats); err != nil {
633 res = append(res, err)
634 }
635
636 if len(res) > 0 {
637 return errors.CompositeValidationError(res...)
638 }
639 return nil
640 }
641
642 func (m *DSSEV001SchemaSignaturesItems0) validateSignature(formats strfmt.Registry) error {
643
644 if err := validate.Required("signature", "body", m.Signature); err != nil {
645 return err
646 }
647
648 if err := validate.Pattern("signature", "body", *m.Signature, `^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{4})$`); err != nil {
649 return err
650 }
651
652 return nil
653 }
654
655 func (m *DSSEV001SchemaSignaturesItems0) validateVerifier(formats strfmt.Registry) error {
656
657 if err := validate.Required("verifier", "body", m.Verifier); err != nil {
658 return err
659 }
660
661 return nil
662 }
663
664
665 func (m *DSSEV001SchemaSignaturesItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
666 return nil
667 }
668
669
670 func (m *DSSEV001SchemaSignaturesItems0) MarshalBinary() ([]byte, error) {
671 if m == nil {
672 return nil, nil
673 }
674 return swag.WriteJSON(m)
675 }
676
677
678 func (m *DSSEV001SchemaSignaturesItems0) UnmarshalBinary(b []byte) error {
679 var res DSSEV001SchemaSignaturesItems0
680 if err := swag.ReadJSON(b, &res); err != nil {
681 return err
682 }
683 *m = res
684 return nil
685 }
686
View as plain text