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

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/type/matcher/path.proto
     3  
     4  package envoy_type_matcher
     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 PathMatcher with the rules defined in
    37  // the proto definition for this message. If any rules are violated, an error
    38  // is returned.
    39  func (m *PathMatcher) Validate() error {
    40  	if m == nil {
    41  		return nil
    42  	}
    43  
    44  	switch m.Rule.(type) {
    45  
    46  	case *PathMatcher_Path:
    47  
    48  		if m.GetPath() == nil {
    49  			return PathMatcherValidationError{
    50  				field:  "Path",
    51  				reason: "value is required",
    52  			}
    53  		}
    54  
    55  		if v, ok := interface{}(m.GetPath()).(interface{ Validate() error }); ok {
    56  			if err := v.Validate(); err != nil {
    57  				return PathMatcherValidationError{
    58  					field:  "Path",
    59  					reason: "embedded message failed validation",
    60  					cause:  err,
    61  				}
    62  			}
    63  		}
    64  
    65  	default:
    66  		return PathMatcherValidationError{
    67  			field:  "Rule",
    68  			reason: "value is required",
    69  		}
    70  
    71  	}
    72  
    73  	return nil
    74  }
    75  
    76  // PathMatcherValidationError is the validation error returned by
    77  // PathMatcher.Validate if the designated constraints aren't met.
    78  type PathMatcherValidationError struct {
    79  	field  string
    80  	reason string
    81  	cause  error
    82  	key    bool
    83  }
    84  
    85  // Field function returns field value.
    86  func (e PathMatcherValidationError) Field() string { return e.field }
    87  
    88  // Reason function returns reason value.
    89  func (e PathMatcherValidationError) Reason() string { return e.reason }
    90  
    91  // Cause function returns cause value.
    92  func (e PathMatcherValidationError) Cause() error { return e.cause }
    93  
    94  // Key function returns key value.
    95  func (e PathMatcherValidationError) Key() bool { return e.key }
    96  
    97  // ErrorName returns error name.
    98  func (e PathMatcherValidationError) ErrorName() string { return "PathMatcherValidationError" }
    99  
   100  // Error satisfies the builtin error interface
   101  func (e PathMatcherValidationError) Error() string {
   102  	cause := ""
   103  	if e.cause != nil {
   104  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   105  	}
   106  
   107  	key := ""
   108  	if e.key {
   109  		key = "key for "
   110  	}
   111  
   112  	return fmt.Sprintf(
   113  		"invalid %sPathMatcher.%s: %s%s",
   114  		key,
   115  		e.field,
   116  		e.reason,
   117  		cause)
   118  }
   119  
   120  var _ error = PathMatcherValidationError{}
   121  
   122  var _ interface {
   123  	Field() string
   124  	Reason() string
   125  	Key() bool
   126  	Cause() error
   127  	ErrorName() string
   128  } = PathMatcherValidationError{}