...
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 InclusionProof struct {
38
39
40
41 Checkpoint *string `json:"checkpoint"`
42
43
44
45 Hashes []string `json:"hashes"`
46
47
48
49
50 LogIndex *int64 `json:"logIndex"`
51
52
53
54
55 RootHash *string `json:"rootHash"`
56
57
58
59
60 TreeSize *int64 `json:"treeSize"`
61 }
62
63
64 func (m *InclusionProof) Validate(formats strfmt.Registry) error {
65 var res []error
66
67 if err := m.validateCheckpoint(formats); err != nil {
68 res = append(res, err)
69 }
70
71 if err := m.validateHashes(formats); err != nil {
72 res = append(res, err)
73 }
74
75 if err := m.validateLogIndex(formats); err != nil {
76 res = append(res, err)
77 }
78
79 if err := m.validateRootHash(formats); err != nil {
80 res = append(res, err)
81 }
82
83 if err := m.validateTreeSize(formats); err != nil {
84 res = append(res, err)
85 }
86
87 if len(res) > 0 {
88 return errors.CompositeValidationError(res...)
89 }
90 return nil
91 }
92
93 func (m *InclusionProof) validateCheckpoint(formats strfmt.Registry) error {
94
95 if err := validate.Required("checkpoint", "body", m.Checkpoint); err != nil {
96 return err
97 }
98
99 return nil
100 }
101
102 func (m *InclusionProof) validateHashes(formats strfmt.Registry) error {
103
104 if err := validate.Required("hashes", "body", m.Hashes); err != nil {
105 return err
106 }
107
108 for i := 0; i < len(m.Hashes); i++ {
109
110 if err := validate.Pattern("hashes"+"."+strconv.Itoa(i), "body", m.Hashes[i], `^[0-9a-fA-F]{64}$`); err != nil {
111 return err
112 }
113
114 }
115
116 return nil
117 }
118
119 func (m *InclusionProof) validateLogIndex(formats strfmt.Registry) error {
120
121 if err := validate.Required("logIndex", "body", m.LogIndex); err != nil {
122 return err
123 }
124
125 if err := validate.MinimumInt("logIndex", "body", *m.LogIndex, 0, false); err != nil {
126 return err
127 }
128
129 return nil
130 }
131
132 func (m *InclusionProof) validateRootHash(formats strfmt.Registry) error {
133
134 if err := validate.Required("rootHash", "body", m.RootHash); err != nil {
135 return err
136 }
137
138 if err := validate.Pattern("rootHash", "body", *m.RootHash, `^[0-9a-fA-F]{64}$`); err != nil {
139 return err
140 }
141
142 return nil
143 }
144
145 func (m *InclusionProof) validateTreeSize(formats strfmt.Registry) error {
146
147 if err := validate.Required("treeSize", "body", m.TreeSize); err != nil {
148 return err
149 }
150
151 if err := validate.MinimumInt("treeSize", "body", *m.TreeSize, 1, false); err != nil {
152 return err
153 }
154
155 return nil
156 }
157
158
159 func (m *InclusionProof) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
160 return nil
161 }
162
163
164 func (m *InclusionProof) MarshalBinary() ([]byte, error) {
165 if m == nil {
166 return nil, nil
167 }
168 return swag.WriteJSON(m)
169 }
170
171
172 func (m *InclusionProof) UnmarshalBinary(b []byte) error {
173 var res InclusionProof
174 if err := swag.ReadJSON(b, &res); err != nil {
175 return err
176 }
177 *m = res
178 return nil
179 }
180
View as plain text