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

Method validate

api/service/data/chain.pb.validate.go:53–94  ·  view source on GitHub ↗
(all bool)

Source from the content-addressed store, hash-verified

51}
52
53func (m *SyncBlockInfoRequest) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 if all {
61 switch v := interface{}(m.GetItem()).(type) {
62 case interface{ ValidateAll() error }:
63 if err := v.ValidateAll(); err != nil {
64 errors = append(errors, SyncBlockInfoRequestValidationError{
65 field: "Item",
66 reason: "embedded message failed validation",
67 cause: err,
68 })
69 }
70 case interface{ Validate() error }:
71 if err := v.Validate(); err != nil {
72 errors = append(errors, SyncBlockInfoRequestValidationError{
73 field: "Item",
74 reason: "embedded message failed validation",
75 cause: err,
76 })
77 }
78 }
79 } else if v, ok := interface{}(m.GetItem()).(interface{ Validate() error }); ok {
80 if err := v.Validate(); err != nil {
81 return SyncBlockInfoRequestValidationError{
82 field: "Item",
83 reason: "embedded message failed validation",
84 cause: err,
85 }
86 }
87 }
88
89 if len(errors) > 0 {
90 return SyncBlockInfoRequestMultiError(errors)
91 }
92
93 return nil
94}
95
96// SyncBlockInfoRequestMultiError is an error wrapping multiple validation
97// errors returned by SyncBlockInfoRequest.ValidateAll() if the designated

Callers 2

ValidateMethod · 0.95
ValidateAllMethod · 0.95

Calls 4

GetItemMethod · 0.95
ValidateAllMethod · 0.45
ValidateMethod · 0.45

Tested by

no test coverage detected