...
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 "strconv"
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 type ConsistencyProof struct {
38
39
40
41 Hashes []string `json:"hashes"`
42
43
44
45
46 RootHash *string `json:"rootHash"`
47 }
48
49
50 func (m *ConsistencyProof) Validate(formats strfmt.Registry) error {
51 var res []error
52
53 if err := m.validateHashes(formats); err != nil {
54 res = append(res, err)
55 }
56
57 if err := m.validateRootHash(formats); err != nil {
58 res = append(res, err)
59 }
60
61 if len(res) > 0 {
62 return errors.CompositeValidationError(res...)
63 }
64 return nil
65 }
66
67 func (m *ConsistencyProof) validateHashes(formats strfmt.Registry) error {
68
69 if err := validate.Required("hashes", "body", m.Hashes); err != nil {
70 return err
71 }
72
73 for i := 0; i < len(m.Hashes); i++ {
74
75 if err := validate.Pattern("hashes"+"."+strconv.Itoa(i), "body", m.Hashes[i], `^[0-9a-fA-F]{64}$`); err != nil {
76 return err
77 }
78
79 }
80
81 return nil
82 }
83
84 func (m *ConsistencyProof) validateRootHash(formats strfmt.Registry) error {
85
86 if err := validate.Required("rootHash", "body", m.RootHash); err != nil {
87 return err
88 }
89
90 if err := validate.Pattern("rootHash", "body", *m.RootHash, `^[0-9a-fA-F]{64}$`); err != nil {
91 return err
92 }
93
94 return nil
95 }
96
97
98 func (m *ConsistencyProof) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
99 return nil
100 }
101
102
103 func (m *ConsistencyProof) MarshalBinary() ([]byte, error) {
104 if m == nil {
105 return nil, nil
106 }
107 return swag.WriteJSON(m)
108 }
109
110
111 func (m *ConsistencyProof) UnmarshalBinary(b []byte) error {
112 var res ConsistencyProof
113 if err := swag.ReadJSON(b, &res); err != nil {
114 return err
115 }
116 *m = res
117 return nil
118 }
119
View as plain text