...

Source file src/github.com/datawire/ambassador/v2/pkg/api/envoy/extensions/common/ratelimit/v3/ratelimit.pb.validate.go

Documentation: github.com/datawire/ambassador/v2/pkg/api/envoy/extensions/common/ratelimit/v3

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/extensions/common/ratelimit/v3/ratelimit.proto
     3  
     4  package envoy_extensions_common_ratelimit_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  	"github.com/golang/protobuf/ptypes"
    19  
    20  	v3 "github.com/datawire/ambassador/v2/pkg/api/envoy/type/v3"
    21  )
    22  
    23  // ensure the imports are used
    24  var (
    25  	_ = bytes.MinRead
    26  	_ = errors.New("")
    27  	_ = fmt.Print
    28  	_ = utf8.UTFMax
    29  	_ = (*regexp.Regexp)(nil)
    30  	_ = (*strings.Reader)(nil)
    31  	_ = net.IPv4len
    32  	_ = time.Duration(0)
    33  	_ = (*url.URL)(nil)
    34  	_ = (*mail.Address)(nil)
    35  	_ = ptypes.DynamicAny{}
    36  
    37  	_ = v3.RateLimitUnit(0)
    38  )
    39  
    40  // Validate checks the field values on RateLimitDescriptor with the rules
    41  // defined in the proto definition for this message. If any rules are
    42  // violated, an error is returned.
    43  func (m *RateLimitDescriptor) Validate() error {
    44  	if m == nil {
    45  		return nil
    46  	}
    47  
    48  	if len(m.GetEntries()) < 1 {
    49  		return RateLimitDescriptorValidationError{
    50  			field:  "Entries",
    51  			reason: "value must contain at least 1 item(s)",
    52  		}
    53  	}
    54  
    55  	for idx, item := range m.GetEntries() {
    56  		_, _ = idx, item
    57  
    58  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
    59  			if err := v.Validate(); err != nil {
    60  				return RateLimitDescriptorValidationError{
    61  					field:  fmt.Sprintf("Entries[%v]", idx),
    62  					reason: "embedded message failed validation",
    63  					cause:  err,
    64  				}
    65  			}
    66  		}
    67  
    68  	}
    69  
    70  	if v, ok := interface{}(m.GetLimit()).(interface{ Validate() error }); ok {
    71  		if err := v.Validate(); err != nil {
    72  			return RateLimitDescriptorValidationError{
    73  				field:  "Limit",
    74  				reason: "embedded message failed validation",
    75  				cause:  err,
    76  			}
    77  		}
    78  	}
    79  
    80  	return nil
    81  }
    82  
    83  // RateLimitDescriptorValidationError is the validation error returned by
    84  // RateLimitDescriptor.Validate if the designated constraints aren't met.
    85  type RateLimitDescriptorValidationError struct {
    86  	field  string
    87  	reason string
    88  	cause  error
    89  	key    bool
    90  }
    91  
    92  // Field function returns field value.
    93  func (e RateLimitDescriptorValidationError) Field() string { return e.field }
    94  
    95  // Reason function returns reason value.
    96  func (e RateLimitDescriptorValidationError) Reason() string { return e.reason }
    97  
    98  // Cause function returns cause value.
    99  func (e RateLimitDescriptorValidationError) Cause() error { return e.cause }
   100  
   101  // Key function returns key value.
   102  func (e RateLimitDescriptorValidationError) Key() bool { return e.key }
   103  
   104  // ErrorName returns error name.
   105  func (e RateLimitDescriptorValidationError) ErrorName() string {
   106  	return "RateLimitDescriptorValidationError"
   107  }
   108  
   109  // Error satisfies the builtin error interface
   110  func (e RateLimitDescriptorValidationError) 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 %sRateLimitDescriptor.%s: %s%s",
   123  		key,
   124  		e.field,
   125  		e.reason,
   126  		cause)
   127  }
   128  
   129  var _ error = RateLimitDescriptorValidationError{}
   130  
   131  var _ interface {
   132  	Field() string
   133  	Reason() string
   134  	Key() bool
   135  	Cause() error
   136  	ErrorName() string
   137  } = RateLimitDescriptorValidationError{}
   138  
   139  // Validate checks the field values on RateLimitDescriptor_Entry with the rules
   140  // defined in the proto definition for this message. If any rules are
   141  // violated, an error is returned.
   142  func (m *RateLimitDescriptor_Entry) Validate() error {
   143  	if m == nil {
   144  		return nil
   145  	}
   146  
   147  	if utf8.RuneCountInString(m.GetKey()) < 1 {
   148  		return RateLimitDescriptor_EntryValidationError{
   149  			field:  "Key",
   150  			reason: "value length must be at least 1 runes",
   151  		}
   152  	}
   153  
   154  	if utf8.RuneCountInString(m.GetValue()) < 1 {
   155  		return RateLimitDescriptor_EntryValidationError{
   156  			field:  "Value",
   157  			reason: "value length must be at least 1 runes",
   158  		}
   159  	}
   160  
   161  	return nil
   162  }
   163  
   164  // RateLimitDescriptor_EntryValidationError is the validation error returned by
   165  // RateLimitDescriptor_Entry.Validate if the designated constraints aren't met.
   166  type RateLimitDescriptor_EntryValidationError struct {
   167  	field  string
   168  	reason string
   169  	cause  error
   170  	key    bool
   171  }
   172  
   173  // Field function returns field value.
   174  func (e RateLimitDescriptor_EntryValidationError) Field() string { return e.field }
   175  
   176  // Reason function returns reason value.
   177  func (e RateLimitDescriptor_EntryValidationError) Reason() string { return e.reason }
   178  
   179  // Cause function returns cause value.
   180  func (e RateLimitDescriptor_EntryValidationError) Cause() error { return e.cause }
   181  
   182  // Key function returns key value.
   183  func (e RateLimitDescriptor_EntryValidationError) Key() bool { return e.key }
   184  
   185  // ErrorName returns error name.
   186  func (e RateLimitDescriptor_EntryValidationError) ErrorName() string {
   187  	return "RateLimitDescriptor_EntryValidationError"
   188  }
   189  
   190  // Error satisfies the builtin error interface
   191  func (e RateLimitDescriptor_EntryValidationError) Error() string {
   192  	cause := ""
   193  	if e.cause != nil {
   194  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   195  	}
   196  
   197  	key := ""
   198  	if e.key {
   199  		key = "key for "
   200  	}
   201  
   202  	return fmt.Sprintf(
   203  		"invalid %sRateLimitDescriptor_Entry.%s: %s%s",
   204  		key,
   205  		e.field,
   206  		e.reason,
   207  		cause)
   208  }
   209  
   210  var _ error = RateLimitDescriptor_EntryValidationError{}
   211  
   212  var _ interface {
   213  	Field() string
   214  	Reason() string
   215  	Key() bool
   216  	Cause() error
   217  	ErrorName() string
   218  } = RateLimitDescriptor_EntryValidationError{}
   219  
   220  // Validate checks the field values on RateLimitDescriptor_RateLimitOverride
   221  // with the rules defined in the proto definition for this message. If any
   222  // rules are violated, an error is returned.
   223  func (m *RateLimitDescriptor_RateLimitOverride) Validate() error {
   224  	if m == nil {
   225  		return nil
   226  	}
   227  
   228  	// no validation rules for RequestsPerUnit
   229  
   230  	if _, ok := v3.RateLimitUnit_name[int32(m.GetUnit())]; !ok {
   231  		return RateLimitDescriptor_RateLimitOverrideValidationError{
   232  			field:  "Unit",
   233  			reason: "value must be one of the defined enum values",
   234  		}
   235  	}
   236  
   237  	return nil
   238  }
   239  
   240  // RateLimitDescriptor_RateLimitOverrideValidationError is the validation error
   241  // returned by RateLimitDescriptor_RateLimitOverride.Validate if the
   242  // designated constraints aren't met.
   243  type RateLimitDescriptor_RateLimitOverrideValidationError struct {
   244  	field  string
   245  	reason string
   246  	cause  error
   247  	key    bool
   248  }
   249  
   250  // Field function returns field value.
   251  func (e RateLimitDescriptor_RateLimitOverrideValidationError) Field() string { return e.field }
   252  
   253  // Reason function returns reason value.
   254  func (e RateLimitDescriptor_RateLimitOverrideValidationError) Reason() string { return e.reason }
   255  
   256  // Cause function returns cause value.
   257  func (e RateLimitDescriptor_RateLimitOverrideValidationError) Cause() error { return e.cause }
   258  
   259  // Key function returns key value.
   260  func (e RateLimitDescriptor_RateLimitOverrideValidationError) Key() bool { return e.key }
   261  
   262  // ErrorName returns error name.
   263  func (e RateLimitDescriptor_RateLimitOverrideValidationError) ErrorName() string {
   264  	return "RateLimitDescriptor_RateLimitOverrideValidationError"
   265  }
   266  
   267  // Error satisfies the builtin error interface
   268  func (e RateLimitDescriptor_RateLimitOverrideValidationError) Error() string {
   269  	cause := ""
   270  	if e.cause != nil {
   271  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   272  	}
   273  
   274  	key := ""
   275  	if e.key {
   276  		key = "key for "
   277  	}
   278  
   279  	return fmt.Sprintf(
   280  		"invalid %sRateLimitDescriptor_RateLimitOverride.%s: %s%s",
   281  		key,
   282  		e.field,
   283  		e.reason,
   284  		cause)
   285  }
   286  
   287  var _ error = RateLimitDescriptor_RateLimitOverrideValidationError{}
   288  
   289  var _ interface {
   290  	Field() string
   291  	Reason() string
   292  	Key() bool
   293  	Cause() error
   294  	ErrorName() string
   295  } = RateLimitDescriptor_RateLimitOverrideValidationError{}
   296  

View as plain text