MCPcopy Create free account
hub / github.com/6boris/web3-template / validate

Method validate

api/interface/web3/demo.pb.validate.go:155–196  ·  view source on GitHub ↗
(all bool)

Source from the content-addressed store, hash-verified

153}
154
155func (m *GetUserReply) validate(all bool) error {
156 if m == nil {
157 return nil
158 }
159
160 var errors []error
161
162 if all {
163 switch v := interface{}(m.GetItem()).(type) {
164 case interface{ ValidateAll() error }:
165 if err := v.ValidateAll(); err != nil {
166 errors = append(errors, GetUserReplyValidationError{
167 field: "Item",
168 reason: "embedded message failed validation",
169 cause: err,
170 })
171 }
172 case interface{ Validate() error }:
173 if err := v.Validate(); err != nil {
174 errors = append(errors, GetUserReplyValidationError{
175 field: "Item",
176 reason: "embedded message failed validation",
177 cause: err,
178 })
179 }
180 }
181 } else if v, ok := interface{}(m.GetItem()).(interface{ Validate() error }); ok {
182 if err := v.Validate(); err != nil {
183 return GetUserReplyValidationError{
184 field: "Item",
185 reason: "embedded message failed validation",
186 cause: err,
187 }
188 }
189 }
190
191 if len(errors) > 0 {
192 return GetUserReplyMultiError(errors)
193 }
194
195 return nil
196}
197
198// GetUserReplyMultiError is an error wrapping multiple validation errors
199// returned by GetUserReply.ValidateAll() if the designated constraints aren't met.

Callers 2

ValidateMethod · 0.95
ValidateAllMethod · 0.95

Calls 4

GetItemMethod · 0.95
GetUserReplyMultiErrorTypeAlias · 0.70
ValidateAllMethod · 0.45
ValidateMethod · 0.45

Tested by

no test coverage detected