github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/config/accesslog/v2/file.pb.validate.go (about)

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