github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/type/hash_policy.pb.validate.go (about)

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