github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/config/core/v3/udp_socket_config.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/config/core/v3/udp_socket_config.proto 3 4 package envoy_config_core_v3 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 UdpSocketConfig with the rules defined 37 // in the proto definition for this message. If any rules are violated, an 38 // error is returned. 39 func (m *UdpSocketConfig) Validate() error { 40 if m == nil { 41 return nil 42 } 43 44 if wrapper := m.GetMaxRxDatagramSize(); wrapper != nil { 45 46 if val := wrapper.GetValue(); val <= 0 || val >= 65536 { 47 return UdpSocketConfigValidationError{ 48 field: "MaxRxDatagramSize", 49 reason: "value must be inside range (0, 65536)", 50 } 51 } 52 53 } 54 55 if v, ok := interface{}(m.GetPreferGro()).(interface{ Validate() error }); ok { 56 if err := v.Validate(); err != nil { 57 return UdpSocketConfigValidationError{ 58 field: "PreferGro", 59 reason: "embedded message failed validation", 60 cause: err, 61 } 62 } 63 } 64 65 return nil 66 } 67 68 // UdpSocketConfigValidationError is the validation error returned by 69 // UdpSocketConfig.Validate if the designated constraints aren't met. 70 type UdpSocketConfigValidationError struct { 71 field string 72 reason string 73 cause error 74 key bool 75 } 76 77 // Field function returns field value. 78 func (e UdpSocketConfigValidationError) Field() string { return e.field } 79 80 // Reason function returns reason value. 81 func (e UdpSocketConfigValidationError) Reason() string { return e.reason } 82 83 // Cause function returns cause value. 84 func (e UdpSocketConfigValidationError) Cause() error { return e.cause } 85 86 // Key function returns key value. 87 func (e UdpSocketConfigValidationError) Key() bool { return e.key } 88 89 // ErrorName returns error name. 90 func (e UdpSocketConfigValidationError) ErrorName() string { return "UdpSocketConfigValidationError" } 91 92 // Error satisfies the builtin error interface 93 func (e UdpSocketConfigValidationError) Error() string { 94 cause := "" 95 if e.cause != nil { 96 cause = fmt.Sprintf(" | caused by: %v", e.cause) 97 } 98 99 key := "" 100 if e.key { 101 key = "key for " 102 } 103 104 return fmt.Sprintf( 105 "invalid %sUdpSocketConfig.%s: %s%s", 106 key, 107 e.field, 108 e.reason, 109 cause) 110 } 111 112 var _ error = UdpSocketConfigValidationError{} 113 114 var _ interface { 115 Field() string 116 Reason() string 117 Key() bool 118 Cause() error 119 ErrorName() string 120 } = UdpSocketConfigValidationError{}