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

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