gitee.com/zhaochuninhefei/gmgo@v0.0.31-0.20240209061119-069254a02979/go-control-plane/envoy/extensions/rate_limit_descriptors/expr/v3/expr.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/extensions/rate_limit_descriptors/expr/v3/expr.proto 3 4 package envoy_extensions_rate_limit_descriptors_expr_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 Descriptor with the rules defined in the 37 // proto definition for this message. If any rules are violated, an error is returned. 38 func (m *Descriptor) Validate() error { 39 if m == nil { 40 return nil 41 } 42 43 if utf8.RuneCountInString(m.GetDescriptorKey()) < 1 { 44 return DescriptorValidationError{ 45 field: "DescriptorKey", 46 reason: "value length must be at least 1 runes", 47 } 48 } 49 50 // no validation rules for SkipIfError 51 52 switch m.ExprSpecifier.(type) { 53 54 case *Descriptor_Text: 55 56 if utf8.RuneCountInString(m.GetText()) < 1 { 57 return DescriptorValidationError{ 58 field: "Text", 59 reason: "value length must be at least 1 runes", 60 } 61 } 62 63 case *Descriptor_Parsed: 64 65 if v, ok := interface{}(m.GetParsed()).(interface{ Validate() error }); ok { 66 if err := v.Validate(); err != nil { 67 return DescriptorValidationError{ 68 field: "Parsed", 69 reason: "embedded message failed validation", 70 cause: err, 71 } 72 } 73 } 74 75 } 76 77 return nil 78 } 79 80 // DescriptorValidationError is the validation error returned by 81 // Descriptor.Validate if the designated constraints aren't met. 82 type DescriptorValidationError struct { 83 field string 84 reason string 85 cause error 86 key bool 87 } 88 89 // Field function returns field value. 90 func (e DescriptorValidationError) Field() string { return e.field } 91 92 // Reason function returns reason value. 93 func (e DescriptorValidationError) Reason() string { return e.reason } 94 95 // Cause function returns cause value. 96 func (e DescriptorValidationError) Cause() error { return e.cause } 97 98 // Key function returns key value. 99 func (e DescriptorValidationError) Key() bool { return e.key } 100 101 // ErrorName returns error name. 102 func (e DescriptorValidationError) ErrorName() string { return "DescriptorValidationError" } 103 104 // Error satisfies the builtin error interface 105 func (e DescriptorValidationError) Error() string { 106 cause := "" 107 if e.cause != nil { 108 cause = fmt.Sprintf(" | caused by: %v", e.cause) 109 } 110 111 key := "" 112 if e.key { 113 key = "key for " 114 } 115 116 return fmt.Sprintf( 117 "invalid %sDescriptor.%s: %s%s", 118 key, 119 e.field, 120 e.reason, 121 cause) 122 } 123 124 var _ error = DescriptorValidationError{} 125 126 var _ interface { 127 Field() string 128 Reason() string 129 Key() bool 130 Cause() error 131 ErrorName() string 132 } = DescriptorValidationError{}