github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/data/tap/v3/wrapper.pb.validate.go (about)

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/data/tap/v3/wrapper.proto
     3  
     4  package envoy_data_tap_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 TraceWrapper 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 *TraceWrapper) Validate() error {
    40  	if m == nil {
    41  		return nil
    42  	}
    43  
    44  	switch m.Trace.(type) {
    45  
    46  	case *TraceWrapper_HttpBufferedTrace:
    47  
    48  		if v, ok := interface{}(m.GetHttpBufferedTrace()).(interface{ Validate() error }); ok {
    49  			if err := v.Validate(); err != nil {
    50  				return TraceWrapperValidationError{
    51  					field:  "HttpBufferedTrace",
    52  					reason: "embedded message failed validation",
    53  					cause:  err,
    54  				}
    55  			}
    56  		}
    57  
    58  	case *TraceWrapper_HttpStreamedTraceSegment:
    59  
    60  		if v, ok := interface{}(m.GetHttpStreamedTraceSegment()).(interface{ Validate() error }); ok {
    61  			if err := v.Validate(); err != nil {
    62  				return TraceWrapperValidationError{
    63  					field:  "HttpStreamedTraceSegment",
    64  					reason: "embedded message failed validation",
    65  					cause:  err,
    66  				}
    67  			}
    68  		}
    69  
    70  	case *TraceWrapper_SocketBufferedTrace:
    71  
    72  		if v, ok := interface{}(m.GetSocketBufferedTrace()).(interface{ Validate() error }); ok {
    73  			if err := v.Validate(); err != nil {
    74  				return TraceWrapperValidationError{
    75  					field:  "SocketBufferedTrace",
    76  					reason: "embedded message failed validation",
    77  					cause:  err,
    78  				}
    79  			}
    80  		}
    81  
    82  	case *TraceWrapper_SocketStreamedTraceSegment:
    83  
    84  		if v, ok := interface{}(m.GetSocketStreamedTraceSegment()).(interface{ Validate() error }); ok {
    85  			if err := v.Validate(); err != nil {
    86  				return TraceWrapperValidationError{
    87  					field:  "SocketStreamedTraceSegment",
    88  					reason: "embedded message failed validation",
    89  					cause:  err,
    90  				}
    91  			}
    92  		}
    93  
    94  	default:
    95  		return TraceWrapperValidationError{
    96  			field:  "Trace",
    97  			reason: "value is required",
    98  		}
    99  
   100  	}
   101  
   102  	return nil
   103  }
   104  
   105  // TraceWrapperValidationError is the validation error returned by
   106  // TraceWrapper.Validate if the designated constraints aren't met.
   107  type TraceWrapperValidationError struct {
   108  	field  string
   109  	reason string
   110  	cause  error
   111  	key    bool
   112  }
   113  
   114  // Field function returns field value.
   115  func (e TraceWrapperValidationError) Field() string { return e.field }
   116  
   117  // Reason function returns reason value.
   118  func (e TraceWrapperValidationError) Reason() string { return e.reason }
   119  
   120  // Cause function returns cause value.
   121  func (e TraceWrapperValidationError) Cause() error { return e.cause }
   122  
   123  // Key function returns key value.
   124  func (e TraceWrapperValidationError) Key() bool { return e.key }
   125  
   126  // ErrorName returns error name.
   127  func (e TraceWrapperValidationError) ErrorName() string { return "TraceWrapperValidationError" }
   128  
   129  // Error satisfies the builtin error interface
   130  func (e TraceWrapperValidationError) Error() string {
   131  	cause := ""
   132  	if e.cause != nil {
   133  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   134  	}
   135  
   136  	key := ""
   137  	if e.key {
   138  		key = "key for "
   139  	}
   140  
   141  	return fmt.Sprintf(
   142  		"invalid %sTraceWrapper.%s: %s%s",
   143  		key,
   144  		e.field,
   145  		e.reason,
   146  		cause)
   147  }
   148  
   149  var _ error = TraceWrapperValidationError{}
   150  
   151  var _ interface {
   152  	Field() string
   153  	Reason() string
   154  	Key() bool
   155  	Cause() error
   156  	ErrorName() string
   157  } = TraceWrapperValidationError{}