github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/extensions/compression/gzip/decompressor/v3/gzip.pb.validate.go (about)

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/extensions/compression/gzip/decompressor/v3/gzip.proto
     3  
     4  package envoy_extensions_compression_gzip_decompressor_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.GetWindowBits(); wrapper != nil {
    44  
    45  		if val := wrapper.GetValue(); val < 9 || val > 15 {
    46  			return GzipValidationError{
    47  				field:  "WindowBits",
    48  				reason: "value must be inside range [9, 15]",
    49  			}
    50  		}
    51  
    52  	}
    53  
    54  	if wrapper := m.GetChunkSize(); wrapper != nil {
    55  
    56  		if val := wrapper.GetValue(); val < 4096 || val > 65536 {
    57  			return GzipValidationError{
    58  				field:  "ChunkSize",
    59  				reason: "value must be inside range [4096, 65536]",
    60  			}
    61  		}
    62  
    63  	}
    64  
    65  	return nil
    66  }
    67  
    68  // GzipValidationError is the validation error returned by Gzip.Validate if the
    69  // designated constraints aren't met.
    70  type GzipValidationError struct {
    71  	field  string
    72  	reason string
    73  	cause  error
    74  	key    bool
    75  }
    76  
    77  // Field function returns field value.
    78  func (e GzipValidationError) Field() string { return e.field }
    79  
    80  // Reason function returns reason value.
    81  func (e GzipValidationError) Reason() string { return e.reason }
    82  
    83  // Cause function returns cause value.
    84  func (e GzipValidationError) Cause() error { return e.cause }
    85  
    86  // Key function returns key value.
    87  func (e GzipValidationError) Key() bool { return e.key }
    88  
    89  // ErrorName returns error name.
    90  func (e GzipValidationError) ErrorName() string { return "GzipValidationError" }
    91  
    92  // Error satisfies the builtin error interface
    93  func (e GzipValidationError) Error() string {
    94  	cause := ""
    95  	if e.cause != nil {
    96  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
    97  	}
    98  
    99  	key := ""
   100  	if e.key {
   101  		key = "key for "
   102  	}
   103  
   104  	return fmt.Sprintf(
   105  		"invalid %sGzip.%s: %s%s",
   106  		key,
   107  		e.field,
   108  		e.reason,
   109  		cause)
   110  }
   111  
   112  var _ error = GzipValidationError{}
   113  
   114  var _ interface {
   115  	Field() string
   116  	Reason() string
   117  	Key() bool
   118  	Cause() error
   119  	ErrorName() string
   120  } = GzipValidationError{}