1// Code generated by protoc-gen-validate. DO NOT EDIT. 2// source: envoy/api/v2/core/socket_option.proto 3 4package envoy_api_v2_core 5 6import ( 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 "github.com/golang/protobuf/ptypes" 19) 20 21// ensure the imports are used 22var ( 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 _ = ptypes.DynamicAny{} 34) 35 36// define the regex for a UUID once up-front 37var _socket_option_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$") 38 39// Validate checks the field values on SocketOption with the rules defined in 40// the proto definition for this message. If any rules are violated, an error 41// is returned. 42func (m *SocketOption) Validate() error { 43 if m == nil { 44 return nil 45 } 46 47 // no validation rules for Description 48 49 // no validation rules for Level 50 51 // no validation rules for Name 52 53 if _, ok := SocketOption_SocketState_name[int32(m.GetState())]; !ok { 54 return SocketOptionValidationError{ 55 field: "State", 56 reason: "value must be one of the defined enum values", 57 } 58 } 59 60 switch m.Value.(type) { 61 62 case *SocketOption_IntValue: 63 // no validation rules for IntValue 64 65 case *SocketOption_BufValue: 66 // no validation rules for BufValue 67 68 default: 69 return SocketOptionValidationError{ 70 field: "Value", 71 reason: "value is required", 72 } 73 74 } 75 76 return nil 77} 78 79// SocketOptionValidationError is the validation error returned by 80// SocketOption.Validate if the designated constraints aren't met. 81type SocketOptionValidationError struct { 82 field string 83 reason string 84 cause error 85 key bool 86} 87 88// Field function returns field value. 89func (e SocketOptionValidationError) Field() string { return e.field } 90 91// Reason function returns reason value. 92func (e SocketOptionValidationError) Reason() string { return e.reason } 93 94// Cause function returns cause value. 95func (e SocketOptionValidationError) Cause() error { return e.cause } 96 97// Key function returns key value. 98func (e SocketOptionValidationError) Key() bool { return e.key } 99 100// ErrorName returns error name. 101func (e SocketOptionValidationError) ErrorName() string { return "SocketOptionValidationError" } 102 103// Error satisfies the builtin error interface 104func (e SocketOptionValidationError) Error() string { 105 cause := "" 106 if e.cause != nil { 107 cause = fmt.Sprintf(" | caused by: %v", e.cause) 108 } 109 110 key := "" 111 if e.key { 112 key = "key for " 113 } 114 115 return fmt.Sprintf( 116 "invalid %sSocketOption.%s: %s%s", 117 key, 118 e.field, 119 e.reason, 120 cause) 121} 122 123var _ error = SocketOptionValidationError{} 124 125var _ interface { 126 Field() string 127 Reason() string 128 Key() bool 129 Cause() error 130 ErrorName() string 131} = SocketOptionValidationError{} 132