github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/extensions/compression/gzip/compressor/v3/gzip.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/extensions/compression/gzip/compressor/v3/gzip.proto 3 4 package envoy_extensions_compression_gzip_compressor_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 Gzip with the rules defined in the proto 37 // definition for this message. If any rules are violated, an error is returned. 38 func (m *Gzip) Validate() error { 39 if m == nil { 40 return nil 41 } 42 43 if wrapper := m.GetMemoryLevel(); wrapper != nil { 44 45 if val := wrapper.GetValue(); val < 1 || val > 9 { 46 return GzipValidationError{ 47 field: "MemoryLevel", 48 reason: "value must be inside range [1, 9]", 49 } 50 } 51 52 } 53 54 if _, ok := Gzip_CompressionLevel_name[int32(m.GetCompressionLevel())]; !ok { 55 return GzipValidationError{ 56 field: "CompressionLevel", 57 reason: "value must be one of the defined enum values", 58 } 59 } 60 61 if _, ok := Gzip_CompressionStrategy_name[int32(m.GetCompressionStrategy())]; !ok { 62 return GzipValidationError{ 63 field: "CompressionStrategy", 64 reason: "value must be one of the defined enum values", 65 } 66 } 67 68 if wrapper := m.GetWindowBits(); wrapper != nil { 69 70 if val := wrapper.GetValue(); val < 9 || val > 15 { 71 return GzipValidationError{ 72 field: "WindowBits", 73 reason: "value must be inside range [9, 15]", 74 } 75 } 76 77 } 78 79 if wrapper := m.GetChunkSize(); wrapper != nil { 80 81 if val := wrapper.GetValue(); val < 4096 || val > 65536 { 82 return GzipValidationError{ 83 field: "ChunkSize", 84 reason: "value must be inside range [4096, 65536]", 85 } 86 } 87 88 } 89 90 return nil 91 } 92 93 // GzipValidationError is the validation error returned by Gzip.Validate if the 94 // designated constraints aren't met. 95 type GzipValidationError struct { 96 field string 97 reason string 98 cause error 99 key bool 100 } 101 102 // Field function returns field value. 103 func (e GzipValidationError) Field() string { return e.field } 104 105 // Reason function returns reason value. 106 func (e GzipValidationError) Reason() string { return e.reason } 107 108 // Cause function returns cause value. 109 func (e GzipValidationError) Cause() error { return e.cause } 110 111 // Key function returns key value. 112 func (e GzipValidationError) Key() bool { return e.key } 113 114 // ErrorName returns error name. 115 func (e GzipValidationError) ErrorName() string { return "GzipValidationError" } 116 117 // Error satisfies the builtin error interface 118 func (e GzipValidationError) Error() string { 119 cause := "" 120 if e.cause != nil { 121 cause = fmt.Sprintf(" | caused by: %v", e.cause) 122 } 123 124 key := "" 125 if e.key { 126 key = "key for " 127 } 128 129 return fmt.Sprintf( 130 "invalid %sGzip.%s: %s%s", 131 key, 132 e.field, 133 e.reason, 134 cause) 135 } 136 137 var _ error = GzipValidationError{} 138 139 var _ interface { 140 Field() string 141 Reason() string 142 Key() bool 143 Cause() error 144 ErrorName() string 145 } = GzipValidationError{}