go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/server/quota/quotapb/update-accounts.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: go.chromium.org/luci/server/quota/quotapb/update-accounts.proto 3 4 package quotapb 5 6 import ( 7 "bytes" 8 "errors" 9 "fmt" 10 "net" 11 "net/mail" 12 "net/url" 13 "regexp" 14 "sort" 15 "strings" 16 "time" 17 "unicode/utf8" 18 19 "google.golang.org/protobuf/types/known/anypb" 20 ) 21 22 // ensure the imports are used 23 var ( 24 _ = bytes.MinRead 25 _ = errors.New("") 26 _ = fmt.Print 27 _ = utf8.UTFMax 28 _ = (*regexp.Regexp)(nil) 29 _ = (*strings.Reader)(nil) 30 _ = net.IPv4len 31 _ = time.Duration(0) 32 _ = (*url.URL)(nil) 33 _ = (*mail.Address)(nil) 34 _ = anypb.Any{} 35 _ = sort.Sort 36 ) 37 38 // Validate checks the field values on UpdateAccountsInput with the rules 39 // defined in the proto definition for this message. If any rules are 40 // violated, the first error encountered is returned, or nil if there are no violations. 41 func (m *UpdateAccountsInput) Validate() error { 42 return m.validate(false) 43 } 44 45 // ValidateAll checks the field values on UpdateAccountsInput with the rules 46 // defined in the proto definition for this message. If any rules are 47 // violated, the result is a list of violation errors wrapped in 48 // UpdateAccountsInputMultiError, or nil if none found. 49 func (m *UpdateAccountsInput) ValidateAll() error { 50 return m.validate(true) 51 } 52 53 func (m *UpdateAccountsInput) validate(all bool) error { 54 if m == nil { 55 return nil 56 } 57 58 var errors []error 59 60 // no validation rules for RequestKey 61 62 if all { 63 switch v := interface{}(m.GetRequestKeyTtl()).(type) { 64 case interface{ ValidateAll() error }: 65 if err := v.ValidateAll(); err != nil { 66 errors = append(errors, UpdateAccountsInputValidationError{ 67 field: "RequestKeyTtl", 68 reason: "embedded message failed validation", 69 cause: err, 70 }) 71 } 72 case interface{ Validate() error }: 73 if err := v.Validate(); err != nil { 74 errors = append(errors, UpdateAccountsInputValidationError{ 75 field: "RequestKeyTtl", 76 reason: "embedded message failed validation", 77 cause: err, 78 }) 79 } 80 } 81 } else if v, ok := interface{}(m.GetRequestKeyTtl()).(interface{ Validate() error }); ok { 82 if err := v.Validate(); err != nil { 83 return UpdateAccountsInputValidationError{ 84 field: "RequestKeyTtl", 85 reason: "embedded message failed validation", 86 cause: err, 87 } 88 } 89 } 90 91 // no validation rules for HashScheme 92 93 // no validation rules for Hash 94 95 for idx, item := range m.GetOps() { 96 _, _ = idx, item 97 98 if all { 99 switch v := interface{}(item).(type) { 100 case interface{ ValidateAll() error }: 101 if err := v.ValidateAll(); err != nil { 102 errors = append(errors, UpdateAccountsInputValidationError{ 103 field: fmt.Sprintf("Ops[%v]", idx), 104 reason: "embedded message failed validation", 105 cause: err, 106 }) 107 } 108 case interface{ Validate() error }: 109 if err := v.Validate(); err != nil { 110 errors = append(errors, UpdateAccountsInputValidationError{ 111 field: fmt.Sprintf("Ops[%v]", idx), 112 reason: "embedded message failed validation", 113 cause: err, 114 }) 115 } 116 } 117 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { 118 if err := v.Validate(); err != nil { 119 return UpdateAccountsInputValidationError{ 120 field: fmt.Sprintf("Ops[%v]", idx), 121 reason: "embedded message failed validation", 122 cause: err, 123 } 124 } 125 } 126 127 } 128 129 if len(errors) > 0 { 130 return UpdateAccountsInputMultiError(errors) 131 } 132 133 return nil 134 } 135 136 // UpdateAccountsInputMultiError is an error wrapping multiple validation 137 // errors returned by UpdateAccountsInput.ValidateAll() if the designated 138 // constraints aren't met. 139 type UpdateAccountsInputMultiError []error 140 141 // Error returns a concatenation of all the error messages it wraps. 142 func (m UpdateAccountsInputMultiError) Error() string { 143 var msgs []string 144 for _, err := range m { 145 msgs = append(msgs, err.Error()) 146 } 147 return strings.Join(msgs, "; ") 148 } 149 150 // AllErrors returns a list of validation violation errors. 151 func (m UpdateAccountsInputMultiError) AllErrors() []error { return m } 152 153 // UpdateAccountsInputValidationError is the validation error returned by 154 // UpdateAccountsInput.Validate if the designated constraints aren't met. 155 type UpdateAccountsInputValidationError struct { 156 field string 157 reason string 158 cause error 159 key bool 160 } 161 162 // Field function returns field value. 163 func (e UpdateAccountsInputValidationError) Field() string { return e.field } 164 165 // Reason function returns reason value. 166 func (e UpdateAccountsInputValidationError) Reason() string { return e.reason } 167 168 // Cause function returns cause value. 169 func (e UpdateAccountsInputValidationError) Cause() error { return e.cause } 170 171 // Key function returns key value. 172 func (e UpdateAccountsInputValidationError) Key() bool { return e.key } 173 174 // ErrorName returns error name. 175 func (e UpdateAccountsInputValidationError) ErrorName() string { 176 return "UpdateAccountsInputValidationError" 177 } 178 179 // Error satisfies the builtin error interface 180 func (e UpdateAccountsInputValidationError) Error() string { 181 cause := "" 182 if e.cause != nil { 183 cause = fmt.Sprintf(" | caused by: %v", e.cause) 184 } 185 186 key := "" 187 if e.key { 188 key = "key for " 189 } 190 191 return fmt.Sprintf( 192 "invalid %sUpdateAccountsInput.%s: %s%s", 193 key, 194 e.field, 195 e.reason, 196 cause) 197 } 198 199 var _ error = UpdateAccountsInputValidationError{} 200 201 var _ interface { 202 Field() string 203 Reason() string 204 Key() bool 205 Cause() error 206 ErrorName() string 207 } = UpdateAccountsInputValidationError{} 208 209 // Validate checks the field values on RawOp with the rules defined in the 210 // proto definition for this message. If any rules are violated, the first 211 // error encountered is returned, or nil if there are no violations. 212 func (m *RawOp) Validate() error { 213 return m.validate(false) 214 } 215 216 // ValidateAll checks the field values on RawOp with the rules defined in the 217 // proto definition for this message. If any rules are violated, the result is 218 // a list of violation errors wrapped in RawOpMultiError, or nil if none found. 219 func (m *RawOp) ValidateAll() error { 220 return m.validate(true) 221 } 222 223 func (m *RawOp) validate(all bool) error { 224 if m == nil { 225 return nil 226 } 227 228 var errors []error 229 230 // no validation rules for AccountRef 231 232 if all { 233 switch v := interface{}(m.GetPolicyRef()).(type) { 234 case interface{ ValidateAll() error }: 235 if err := v.ValidateAll(); err != nil { 236 errors = append(errors, RawOpValidationError{ 237 field: "PolicyRef", 238 reason: "embedded message failed validation", 239 cause: err, 240 }) 241 } 242 case interface{ Validate() error }: 243 if err := v.Validate(); err != nil { 244 errors = append(errors, RawOpValidationError{ 245 field: "PolicyRef", 246 reason: "embedded message failed validation", 247 cause: err, 248 }) 249 } 250 } 251 } else if v, ok := interface{}(m.GetPolicyRef()).(interface{ Validate() error }); ok { 252 if err := v.Validate(); err != nil { 253 return RawOpValidationError{ 254 field: "PolicyRef", 255 reason: "embedded message failed validation", 256 cause: err, 257 } 258 } 259 } 260 261 // no validation rules for RelativeTo 262 263 // no validation rules for Delta 264 265 // no validation rules for Options 266 267 if len(errors) > 0 { 268 return RawOpMultiError(errors) 269 } 270 271 return nil 272 } 273 274 // RawOpMultiError is an error wrapping multiple validation errors returned by 275 // RawOp.ValidateAll() if the designated constraints aren't met. 276 type RawOpMultiError []error 277 278 // Error returns a concatenation of all the error messages it wraps. 279 func (m RawOpMultiError) Error() string { 280 var msgs []string 281 for _, err := range m { 282 msgs = append(msgs, err.Error()) 283 } 284 return strings.Join(msgs, "; ") 285 } 286 287 // AllErrors returns a list of validation violation errors. 288 func (m RawOpMultiError) AllErrors() []error { return m } 289 290 // RawOpValidationError is the validation error returned by RawOp.Validate if 291 // the designated constraints aren't met. 292 type RawOpValidationError struct { 293 field string 294 reason string 295 cause error 296 key bool 297 } 298 299 // Field function returns field value. 300 func (e RawOpValidationError) Field() string { return e.field } 301 302 // Reason function returns reason value. 303 func (e RawOpValidationError) Reason() string { return e.reason } 304 305 // Cause function returns cause value. 306 func (e RawOpValidationError) Cause() error { return e.cause } 307 308 // Key function returns key value. 309 func (e RawOpValidationError) Key() bool { return e.key } 310 311 // ErrorName returns error name. 312 func (e RawOpValidationError) ErrorName() string { return "RawOpValidationError" } 313 314 // Error satisfies the builtin error interface 315 func (e RawOpValidationError) Error() string { 316 cause := "" 317 if e.cause != nil { 318 cause = fmt.Sprintf(" | caused by: %v", e.cause) 319 } 320 321 key := "" 322 if e.key { 323 key = "key for " 324 } 325 326 return fmt.Sprintf( 327 "invalid %sRawOp.%s: %s%s", 328 key, 329 e.field, 330 e.reason, 331 cause) 332 } 333 334 var _ error = RawOpValidationError{} 335 336 var _ interface { 337 Field() string 338 Reason() string 339 Key() bool 340 Cause() error 341 ErrorName() string 342 } = RawOpValidationError{}