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

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/extensions/transport_sockets/starttls/v3/starttls.proto
     3  
     4  package envoy_extensions_transport_sockets_starttls_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 StartTlsConfig 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 *StartTlsConfig) Validate() error {
    40  	if m == nil {
    41  		return nil
    42  	}
    43  
    44  	if v, ok := interface{}(m.GetCleartextSocketConfig()).(interface{ Validate() error }); ok {
    45  		if err := v.Validate(); err != nil {
    46  			return StartTlsConfigValidationError{
    47  				field:  "CleartextSocketConfig",
    48  				reason: "embedded message failed validation",
    49  				cause:  err,
    50  			}
    51  		}
    52  	}
    53  
    54  	if m.GetTlsSocketConfig() == nil {
    55  		return StartTlsConfigValidationError{
    56  			field:  "TlsSocketConfig",
    57  			reason: "value is required",
    58  		}
    59  	}
    60  
    61  	if v, ok := interface{}(m.GetTlsSocketConfig()).(interface{ Validate() error }); ok {
    62  		if err := v.Validate(); err != nil {
    63  			return StartTlsConfigValidationError{
    64  				field:  "TlsSocketConfig",
    65  				reason: "embedded message failed validation",
    66  				cause:  err,
    67  			}
    68  		}
    69  	}
    70  
    71  	return nil
    72  }
    73  
    74  // StartTlsConfigValidationError is the validation error returned by
    75  // StartTlsConfig.Validate if the designated constraints aren't met.
    76  type StartTlsConfigValidationError struct {
    77  	field  string
    78  	reason string
    79  	cause  error
    80  	key    bool
    81  }
    82  
    83  // Field function returns field value.
    84  func (e StartTlsConfigValidationError) Field() string { return e.field }
    85  
    86  // Reason function returns reason value.
    87  func (e StartTlsConfigValidationError) Reason() string { return e.reason }
    88  
    89  // Cause function returns cause value.
    90  func (e StartTlsConfigValidationError) Cause() error { return e.cause }
    91  
    92  // Key function returns key value.
    93  func (e StartTlsConfigValidationError) Key() bool { return e.key }
    94  
    95  // ErrorName returns error name.
    96  func (e StartTlsConfigValidationError) ErrorName() string { return "StartTlsConfigValidationError" }
    97  
    98  // Error satisfies the builtin error interface
    99  func (e StartTlsConfigValidationError) Error() string {
   100  	cause := ""
   101  	if e.cause != nil {
   102  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   103  	}
   104  
   105  	key := ""
   106  	if e.key {
   107  		key = "key for "
   108  	}
   109  
   110  	return fmt.Sprintf(
   111  		"invalid %sStartTlsConfig.%s: %s%s",
   112  		key,
   113  		e.field,
   114  		e.reason,
   115  		cause)
   116  }
   117  
   118  var _ error = StartTlsConfigValidationError{}
   119  
   120  var _ interface {
   121  	Field() string
   122  	Reason() string
   123  	Key() bool
   124  	Cause() error
   125  	ErrorName() string
   126  } = StartTlsConfigValidationError{}
   127  
   128  // Validate checks the field values on UpstreamStartTlsConfig with the rules
   129  // defined in the proto definition for this message. If any rules are
   130  // violated, an error is returned.
   131  func (m *UpstreamStartTlsConfig) Validate() error {
   132  	if m == nil {
   133  		return nil
   134  	}
   135  
   136  	if v, ok := interface{}(m.GetCleartextSocketConfig()).(interface{ Validate() error }); ok {
   137  		if err := v.Validate(); err != nil {
   138  			return UpstreamStartTlsConfigValidationError{
   139  				field:  "CleartextSocketConfig",
   140  				reason: "embedded message failed validation",
   141  				cause:  err,
   142  			}
   143  		}
   144  	}
   145  
   146  	if m.GetTlsSocketConfig() == nil {
   147  		return UpstreamStartTlsConfigValidationError{
   148  			field:  "TlsSocketConfig",
   149  			reason: "value is required",
   150  		}
   151  	}
   152  
   153  	if v, ok := interface{}(m.GetTlsSocketConfig()).(interface{ Validate() error }); ok {
   154  		if err := v.Validate(); err != nil {
   155  			return UpstreamStartTlsConfigValidationError{
   156  				field:  "TlsSocketConfig",
   157  				reason: "embedded message failed validation",
   158  				cause:  err,
   159  			}
   160  		}
   161  	}
   162  
   163  	return nil
   164  }
   165  
   166  // UpstreamStartTlsConfigValidationError is the validation error returned by
   167  // UpstreamStartTlsConfig.Validate if the designated constraints aren't met.
   168  type UpstreamStartTlsConfigValidationError struct {
   169  	field  string
   170  	reason string
   171  	cause  error
   172  	key    bool
   173  }
   174  
   175  // Field function returns field value.
   176  func (e UpstreamStartTlsConfigValidationError) Field() string { return e.field }
   177  
   178  // Reason function returns reason value.
   179  func (e UpstreamStartTlsConfigValidationError) Reason() string { return e.reason }
   180  
   181  // Cause function returns cause value.
   182  func (e UpstreamStartTlsConfigValidationError) Cause() error { return e.cause }
   183  
   184  // Key function returns key value.
   185  func (e UpstreamStartTlsConfigValidationError) Key() bool { return e.key }
   186  
   187  // ErrorName returns error name.
   188  func (e UpstreamStartTlsConfigValidationError) ErrorName() string {
   189  	return "UpstreamStartTlsConfigValidationError"
   190  }
   191  
   192  // Error satisfies the builtin error interface
   193  func (e UpstreamStartTlsConfigValidationError) Error() string {
   194  	cause := ""
   195  	if e.cause != nil {
   196  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   197  	}
   198  
   199  	key := ""
   200  	if e.key {
   201  		key = "key for "
   202  	}
   203  
   204  	return fmt.Sprintf(
   205  		"invalid %sUpstreamStartTlsConfig.%s: %s%s",
   206  		key,
   207  		e.field,
   208  		e.reason,
   209  		cause)
   210  }
   211  
   212  var _ error = UpstreamStartTlsConfigValidationError{}
   213  
   214  var _ interface {
   215  	Field() string
   216  	Reason() string
   217  	Key() bool
   218  	Cause() error
   219  	ErrorName() string
   220  } = UpstreamStartTlsConfigValidationError{}