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