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