github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/config/transport_socket/tap/v2alpha/tap.pb.validate.go (about)

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/config/transport_socket/tap/v2alpha/tap.proto
     3  
     4  package envoy_config_transport_socket_tap_v2alpha
     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 Tap with the rules defined in the proto
    37  // definition for this message. If any rules are violated, an error is returned.
    38  func (m *Tap) Validate() error {
    39  	if m == nil {
    40  		return nil
    41  	}
    42  
    43  	if m.GetCommonConfig() == nil {
    44  		return TapValidationError{
    45  			field:  "CommonConfig",
    46  			reason: "value is required",
    47  		}
    48  	}
    49  
    50  	if v, ok := interface{}(m.GetCommonConfig()).(interface{ Validate() error }); ok {
    51  		if err := v.Validate(); err != nil {
    52  			return TapValidationError{
    53  				field:  "CommonConfig",
    54  				reason: "embedded message failed validation",
    55  				cause:  err,
    56  			}
    57  		}
    58  	}
    59  
    60  	if m.GetTransportSocket() == nil {
    61  		return TapValidationError{
    62  			field:  "TransportSocket",
    63  			reason: "value is required",
    64  		}
    65  	}
    66  
    67  	if v, ok := interface{}(m.GetTransportSocket()).(interface{ Validate() error }); ok {
    68  		if err := v.Validate(); err != nil {
    69  			return TapValidationError{
    70  				field:  "TransportSocket",
    71  				reason: "embedded message failed validation",
    72  				cause:  err,
    73  			}
    74  		}
    75  	}
    76  
    77  	return nil
    78  }
    79  
    80  // TapValidationError is the validation error returned by Tap.Validate if the
    81  // designated constraints aren't met.
    82  type TapValidationError struct {
    83  	field  string
    84  	reason string
    85  	cause  error
    86  	key    bool
    87  }
    88  
    89  // Field function returns field value.
    90  func (e TapValidationError) Field() string { return e.field }
    91  
    92  // Reason function returns reason value.
    93  func (e TapValidationError) Reason() string { return e.reason }
    94  
    95  // Cause function returns cause value.
    96  func (e TapValidationError) Cause() error { return e.cause }
    97  
    98  // Key function returns key value.
    99  func (e TapValidationError) Key() bool { return e.key }
   100  
   101  // ErrorName returns error name.
   102  func (e TapValidationError) ErrorName() string { return "TapValidationError" }
   103  
   104  // Error satisfies the builtin error interface
   105  func (e TapValidationError) Error() string {
   106  	cause := ""
   107  	if e.cause != nil {
   108  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   109  	}
   110  
   111  	key := ""
   112  	if e.key {
   113  		key = "key for "
   114  	}
   115  
   116  	return fmt.Sprintf(
   117  		"invalid %sTap.%s: %s%s",
   118  		key,
   119  		e.field,
   120  		e.reason,
   121  		cause)
   122  }
   123  
   124  var _ error = TapValidationError{}
   125  
   126  var _ interface {
   127  	Field() string
   128  	Reason() string
   129  	Key() bool
   130  	Cause() error
   131  	ErrorName() string
   132  } = TapValidationError{}