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

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/extensions/compression/brotli/decompressor/v3/brotli.proto
     3  
     4  package envoy_extensions_compression_brotli_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 Brotli with the rules defined in the
    37  // proto definition for this message. If any rules are violated, an error is returned.
    38  func (m *Brotli) Validate() error {
    39  	if m == nil {
    40  		return nil
    41  	}
    42  
    43  	// no validation rules for DisableRingBufferReallocation
    44  
    45  	if wrapper := m.GetChunkSize(); wrapper != nil {
    46  
    47  		if val := wrapper.GetValue(); val < 4096 || val > 65536 {
    48  			return BrotliValidationError{
    49  				field:  "ChunkSize",
    50  				reason: "value must be inside range [4096, 65536]",
    51  			}
    52  		}
    53  
    54  	}
    55  
    56  	return nil
    57  }
    58  
    59  // BrotliValidationError is the validation error returned by Brotli.Validate if
    60  // the designated constraints aren't met.
    61  type BrotliValidationError struct {
    62  	field  string
    63  	reason string
    64  	cause  error
    65  	key    bool
    66  }
    67  
    68  // Field function returns field value.
    69  func (e BrotliValidationError) Field() string { return e.field }
    70  
    71  // Reason function returns reason value.
    72  func (e BrotliValidationError) Reason() string { return e.reason }
    73  
    74  // Cause function returns cause value.
    75  func (e BrotliValidationError) Cause() error { return e.cause }
    76  
    77  // Key function returns key value.
    78  func (e BrotliValidationError) Key() bool { return e.key }
    79  
    80  // ErrorName returns error name.
    81  func (e BrotliValidationError) ErrorName() string { return "BrotliValidationError" }
    82  
    83  // Error satisfies the builtin error interface
    84  func (e BrotliValidationError) Error() string {
    85  	cause := ""
    86  	if e.cause != nil {
    87  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
    88  	}
    89  
    90  	key := ""
    91  	if e.key {
    92  		key = "key for "
    93  	}
    94  
    95  	return fmt.Sprintf(
    96  		"invalid %sBrotli.%s: %s%s",
    97  		key,
    98  		e.field,
    99  		e.reason,
   100  		cause)
   101  }
   102  
   103  var _ error = BrotliValidationError{}
   104  
   105  var _ interface {
   106  	Field() string
   107  	Reason() string
   108  	Key() bool
   109  	Cause() error
   110  	ErrorName() string
   111  } = BrotliValidationError{}