gitee.com/zhaochuninhefei/gmgo@v0.0.31-0.20240209061119-069254a02979/go-control-plane/envoy/type/matcher/node.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/type/matcher/node.proto 3 4 package envoy_type_matcher 5 6 import ( 7 "bytes" 8 "errors" 9 "fmt" 10 "net" 11 "net/mail" 12 "net/url" 13 "regexp" 14 "strings" 15 "time" 16 "unicode/utf8" 17 18 "google.golang.org/protobuf/types/known/anypb" 19 ) 20 21 // ensure the imports are used 22 var ( 23 _ = bytes.MinRead 24 _ = errors.New("") 25 _ = fmt.Print 26 _ = utf8.UTFMax 27 _ = (*regexp.Regexp)(nil) 28 _ = (*strings.Reader)(nil) 29 _ = net.IPv4len 30 _ = time.Duration(0) 31 _ = (*url.URL)(nil) 32 _ = (*mail.Address)(nil) 33 _ = anypb.Any{} 34 ) 35 36 // Validate checks the field values on NodeMatcher with the rules defined in 37 // the proto definition for this message. If any rules are violated, an error 38 // is returned. 39 func (m *NodeMatcher) Validate() error { 40 if m == nil { 41 return nil 42 } 43 44 if v, ok := interface{}(m.GetNodeId()).(interface{ Validate() error }); ok { 45 if err := v.Validate(); err != nil { 46 return NodeMatcherValidationError{ 47 field: "NodeId", 48 reason: "embedded message failed validation", 49 cause: err, 50 } 51 } 52 } 53 54 for idx, item := range m.GetNodeMetadatas() { 55 _, _ = idx, item 56 57 if v, ok := interface{}(item).(interface{ Validate() error }); ok { 58 if err := v.Validate(); err != nil { 59 return NodeMatcherValidationError{ 60 field: fmt.Sprintf("NodeMetadatas[%v]", idx), 61 reason: "embedded message failed validation", 62 cause: err, 63 } 64 } 65 } 66 67 } 68 69 return nil 70 } 71 72 // NodeMatcherValidationError is the validation error returned by 73 // NodeMatcher.Validate if the designated constraints aren't met. 74 type NodeMatcherValidationError struct { 75 field string 76 reason string 77 cause error 78 key bool 79 } 80 81 // Field function returns field value. 82 func (e NodeMatcherValidationError) Field() string { return e.field } 83 84 // Reason function returns reason value. 85 func (e NodeMatcherValidationError) Reason() string { return e.reason } 86 87 // Cause function returns cause value. 88 func (e NodeMatcherValidationError) Cause() error { return e.cause } 89 90 // Key function returns key value. 91 func (e NodeMatcherValidationError) Key() bool { return e.key } 92 93 // ErrorName returns error name. 94 func (e NodeMatcherValidationError) ErrorName() string { return "NodeMatcherValidationError" } 95 96 // Error satisfies the builtin error interface 97 func (e NodeMatcherValidationError) Error() string { 98 cause := "" 99 if e.cause != nil { 100 cause = fmt.Sprintf(" | caused by: %v", e.cause) 101 } 102 103 key := "" 104 if e.key { 105 key = "key for " 106 } 107 108 return fmt.Sprintf( 109 "invalid %sNodeMatcher.%s: %s%s", 110 key, 111 e.field, 112 e.reason, 113 cause) 114 } 115 116 var _ error = NodeMatcherValidationError{} 117 118 var _ interface { 119 Field() string 120 Reason() string 121 Key() bool 122 Cause() error 123 ErrorName() string 124 } = NodeMatcherValidationError{}