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

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