github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/config/trace/v3/xray.pb.validate.go (about)

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