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

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