github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/extensions/watchdog/profile_action/v3alpha/profile_action.pb.validate.go (about)

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/extensions/watchdog/profile_action/v3alpha/profile_action.proto
     3  
     4  package envoy_extensions_watchdog_profile_action_v3alpha
     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 ProfileActionConfig 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 *ProfileActionConfig) Validate() error {
    40  	if m == nil {
    41  		return nil
    42  	}
    43  
    44  	if v, ok := interface{}(m.GetProfileDuration()).(interface{ Validate() error }); ok {
    45  		if err := v.Validate(); err != nil {
    46  			return ProfileActionConfigValidationError{
    47  				field:  "ProfileDuration",
    48  				reason: "embedded message failed validation",
    49  				cause:  err,
    50  			}
    51  		}
    52  	}
    53  
    54  	if utf8.RuneCountInString(m.GetProfilePath()) < 1 {
    55  		return ProfileActionConfigValidationError{
    56  			field:  "ProfilePath",
    57  			reason: "value length must be at least 1 runes",
    58  		}
    59  	}
    60  
    61  	// no validation rules for MaxProfiles
    62  
    63  	return nil
    64  }
    65  
    66  // ProfileActionConfigValidationError is the validation error returned by
    67  // ProfileActionConfig.Validate if the designated constraints aren't met.
    68  type ProfileActionConfigValidationError struct {
    69  	field  string
    70  	reason string
    71  	cause  error
    72  	key    bool
    73  }
    74  
    75  // Field function returns field value.
    76  func (e ProfileActionConfigValidationError) Field() string { return e.field }
    77  
    78  // Reason function returns reason value.
    79  func (e ProfileActionConfigValidationError) Reason() string { return e.reason }
    80  
    81  // Cause function returns cause value.
    82  func (e ProfileActionConfigValidationError) Cause() error { return e.cause }
    83  
    84  // Key function returns key value.
    85  func (e ProfileActionConfigValidationError) Key() bool { return e.key }
    86  
    87  // ErrorName returns error name.
    88  func (e ProfileActionConfigValidationError) ErrorName() string {
    89  	return "ProfileActionConfigValidationError"
    90  }
    91  
    92  // Error satisfies the builtin error interface
    93  func (e ProfileActionConfigValidationError) 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 %sProfileActionConfig.%s: %s%s",
   106  		key,
   107  		e.field,
   108  		e.reason,
   109  		cause)
   110  }
   111  
   112  var _ error = ProfileActionConfigValidationError{}
   113  
   114  var _ interface {
   115  	Field() string
   116  	Reason() string
   117  	Key() bool
   118  	Cause() error
   119  	ErrorName() string
   120  } = ProfileActionConfigValidationError{}