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

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/extensions/stat_sinks/graphite_statsd/v3/graphite_statsd.proto
     3  
     4  package envoy_extensions_stat_sinks_graphite_statsd_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 GraphiteStatsdSink 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 *GraphiteStatsdSink) Validate() error {
    40  	if m == nil {
    41  		return nil
    42  	}
    43  
    44  	// no validation rules for Prefix
    45  
    46  	if wrapper := m.GetMaxBytesPerDatagram(); wrapper != nil {
    47  
    48  		if wrapper.GetValue() <= 0 {
    49  			return GraphiteStatsdSinkValidationError{
    50  				field:  "MaxBytesPerDatagram",
    51  				reason: "value must be greater than 0",
    52  			}
    53  		}
    54  
    55  	}
    56  
    57  	switch m.StatsdSpecifier.(type) {
    58  
    59  	case *GraphiteStatsdSink_Address:
    60  
    61  		if v, ok := interface{}(m.GetAddress()).(interface{ Validate() error }); ok {
    62  			if err := v.Validate(); err != nil {
    63  				return GraphiteStatsdSinkValidationError{
    64  					field:  "Address",
    65  					reason: "embedded message failed validation",
    66  					cause:  err,
    67  				}
    68  			}
    69  		}
    70  
    71  	default:
    72  		return GraphiteStatsdSinkValidationError{
    73  			field:  "StatsdSpecifier",
    74  			reason: "value is required",
    75  		}
    76  
    77  	}
    78  
    79  	return nil
    80  }
    81  
    82  // GraphiteStatsdSinkValidationError is the validation error returned by
    83  // GraphiteStatsdSink.Validate if the designated constraints aren't met.
    84  type GraphiteStatsdSinkValidationError struct {
    85  	field  string
    86  	reason string
    87  	cause  error
    88  	key    bool
    89  }
    90  
    91  // Field function returns field value.
    92  func (e GraphiteStatsdSinkValidationError) Field() string { return e.field }
    93  
    94  // Reason function returns reason value.
    95  func (e GraphiteStatsdSinkValidationError) Reason() string { return e.reason }
    96  
    97  // Cause function returns cause value.
    98  func (e GraphiteStatsdSinkValidationError) Cause() error { return e.cause }
    99  
   100  // Key function returns key value.
   101  func (e GraphiteStatsdSinkValidationError) Key() bool { return e.key }
   102  
   103  // ErrorName returns error name.
   104  func (e GraphiteStatsdSinkValidationError) ErrorName() string {
   105  	return "GraphiteStatsdSinkValidationError"
   106  }
   107  
   108  // Error satisfies the builtin error interface
   109  func (e GraphiteStatsdSinkValidationError) Error() string {
   110  	cause := ""
   111  	if e.cause != nil {
   112  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   113  	}
   114  
   115  	key := ""
   116  	if e.key {
   117  		key = "key for "
   118  	}
   119  
   120  	return fmt.Sprintf(
   121  		"invalid %sGraphiteStatsdSink.%s: %s%s",
   122  		key,
   123  		e.field,
   124  		e.reason,
   125  		cause)
   126  }
   127  
   128  var _ error = GraphiteStatsdSinkValidationError{}
   129  
   130  var _ interface {
   131  	Field() string
   132  	Reason() string
   133  	Key() bool
   134  	Cause() error
   135  	ErrorName() string
   136  } = GraphiteStatsdSinkValidationError{}