gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/go-control-plane/envoy/api/v2/ratelimit/ratelimit.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/api/v2/ratelimit/ratelimit.proto 3 4 package envoy_api_v2_ratelimit 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 RateLimitDescriptor with the rules 37 // defined in the proto definition for this message. If any rules are 38 // violated, an error is returned. 39 func (m *RateLimitDescriptor) Validate() error { 40 if m == nil { 41 return nil 42 } 43 44 if len(m.GetEntries()) < 1 { 45 return RateLimitDescriptorValidationError{ 46 field: "Entries", 47 reason: "value must contain at least 1 item(s)", 48 } 49 } 50 51 for idx, item := range m.GetEntries() { 52 _, _ = idx, item 53 54 if v, ok := interface{}(item).(interface{ Validate() error }); ok { 55 if err := v.Validate(); err != nil { 56 return RateLimitDescriptorValidationError{ 57 field: fmt.Sprintf("Entries[%v]", idx), 58 reason: "embedded message failed validation", 59 cause: err, 60 } 61 } 62 } 63 64 } 65 66 return nil 67 } 68 69 // RateLimitDescriptorValidationError is the validation error returned by 70 // RateLimitDescriptor.Validate if the designated constraints aren't met. 71 type RateLimitDescriptorValidationError struct { 72 field string 73 reason string 74 cause error 75 key bool 76 } 77 78 // Field function returns field value. 79 func (e RateLimitDescriptorValidationError) Field() string { return e.field } 80 81 // Reason function returns reason value. 82 func (e RateLimitDescriptorValidationError) Reason() string { return e.reason } 83 84 // Cause function returns cause value. 85 func (e RateLimitDescriptorValidationError) Cause() error { return e.cause } 86 87 // Key function returns key value. 88 func (e RateLimitDescriptorValidationError) Key() bool { return e.key } 89 90 // ErrorName returns error name. 91 func (e RateLimitDescriptorValidationError) ErrorName() string { 92 return "RateLimitDescriptorValidationError" 93 } 94 95 // Error satisfies the builtin error interface 96 func (e RateLimitDescriptorValidationError) Error() string { 97 cause := "" 98 if e.cause != nil { 99 cause = fmt.Sprintf(" | caused by: %v", e.cause) 100 } 101 102 key := "" 103 if e.key { 104 key = "key for " 105 } 106 107 return fmt.Sprintf( 108 "invalid %sRateLimitDescriptor.%s: %s%s", 109 key, 110 e.field, 111 e.reason, 112 cause) 113 } 114 115 var _ error = RateLimitDescriptorValidationError{} 116 117 var _ interface { 118 Field() string 119 Reason() string 120 Key() bool 121 Cause() error 122 ErrorName() string 123 } = RateLimitDescriptorValidationError{} 124 125 // Validate checks the field values on RateLimitDescriptor_Entry with the rules 126 // defined in the proto definition for this message. If any rules are 127 // violated, an error is returned. 128 func (m *RateLimitDescriptor_Entry) Validate() error { 129 if m == nil { 130 return nil 131 } 132 133 if len(m.GetKey()) < 1 { 134 return RateLimitDescriptor_EntryValidationError{ 135 field: "Key", 136 reason: "value length must be at least 1 bytes", 137 } 138 } 139 140 if len(m.GetValue()) < 1 { 141 return RateLimitDescriptor_EntryValidationError{ 142 field: "Value", 143 reason: "value length must be at least 1 bytes", 144 } 145 } 146 147 return nil 148 } 149 150 // RateLimitDescriptor_EntryValidationError is the validation error returned by 151 // RateLimitDescriptor_Entry.Validate if the designated constraints aren't met. 152 type RateLimitDescriptor_EntryValidationError struct { 153 field string 154 reason string 155 cause error 156 key bool 157 } 158 159 // Field function returns field value. 160 func (e RateLimitDescriptor_EntryValidationError) Field() string { return e.field } 161 162 // Reason function returns reason value. 163 func (e RateLimitDescriptor_EntryValidationError) Reason() string { return e.reason } 164 165 // Cause function returns cause value. 166 func (e RateLimitDescriptor_EntryValidationError) Cause() error { return e.cause } 167 168 // Key function returns key value. 169 func (e RateLimitDescriptor_EntryValidationError) Key() bool { return e.key } 170 171 // ErrorName returns error name. 172 func (e RateLimitDescriptor_EntryValidationError) ErrorName() string { 173 return "RateLimitDescriptor_EntryValidationError" 174 } 175 176 // Error satisfies the builtin error interface 177 func (e RateLimitDescriptor_EntryValidationError) Error() string { 178 cause := "" 179 if e.cause != nil { 180 cause = fmt.Sprintf(" | caused by: %v", e.cause) 181 } 182 183 key := "" 184 if e.key { 185 key = "key for " 186 } 187 188 return fmt.Sprintf( 189 "invalid %sRateLimitDescriptor_Entry.%s: %s%s", 190 key, 191 e.field, 192 e.reason, 193 cause) 194 } 195 196 var _ error = RateLimitDescriptor_EntryValidationError{} 197 198 var _ interface { 199 Field() string 200 Reason() string 201 Key() bool 202 Cause() error 203 ErrorName() string 204 } = RateLimitDescriptor_EntryValidationError{}