...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/api/envoy/service/discovery/v2/rtds.pb.validate.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/api/envoy/service/discovery/v2

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/service/discovery/v2/rtds.proto
     3  
     4  package discoveryv2
     5  
     6  import (
     7  	"bytes"
     8  	"errors"
     9  	"fmt"
    10  	"net"
    11  	"net/mail"
    12  	"net/url"
    13  	"regexp"
    14  	"sort"
    15  	"strings"
    16  	"time"
    17  	"unicode/utf8"
    18  
    19  	"google.golang.org/protobuf/types/known/anypb"
    20  )
    21  
    22  // ensure the imports are used
    23  var (
    24  	_ = bytes.MinRead
    25  	_ = errors.New("")
    26  	_ = fmt.Print
    27  	_ = utf8.UTFMax
    28  	_ = (*regexp.Regexp)(nil)
    29  	_ = (*strings.Reader)(nil)
    30  	_ = net.IPv4len
    31  	_ = time.Duration(0)
    32  	_ = (*url.URL)(nil)
    33  	_ = (*mail.Address)(nil)
    34  	_ = anypb.Any{}
    35  	_ = sort.Sort
    36  )
    37  
    38  // Validate checks the field values on RtdsDummy with the rules defined in the
    39  // proto definition for this message. If any rules are violated, the first
    40  // error encountered is returned, or nil if there are no violations.
    41  func (m *RtdsDummy) Validate() error {
    42  	return m.validate(false)
    43  }
    44  
    45  // ValidateAll checks the field values on RtdsDummy with the rules defined in
    46  // the proto definition for this message. If any rules are violated, the
    47  // result is a list of violation errors wrapped in RtdsDummyMultiError, or nil
    48  // if none found.
    49  func (m *RtdsDummy) ValidateAll() error {
    50  	return m.validate(true)
    51  }
    52  
    53  func (m *RtdsDummy) validate(all bool) error {
    54  	if m == nil {
    55  		return nil
    56  	}
    57  
    58  	var errors []error
    59  
    60  	if len(errors) > 0 {
    61  		return RtdsDummyMultiError(errors)
    62  	}
    63  
    64  	return nil
    65  }
    66  
    67  // RtdsDummyMultiError is an error wrapping multiple validation errors returned
    68  // by RtdsDummy.ValidateAll() if the designated constraints aren't met.
    69  type RtdsDummyMultiError []error
    70  
    71  // Error returns a concatenation of all the error messages it wraps.
    72  func (m RtdsDummyMultiError) Error() string {
    73  	var msgs []string
    74  	for _, err := range m {
    75  		msgs = append(msgs, err.Error())
    76  	}
    77  	return strings.Join(msgs, "; ")
    78  }
    79  
    80  // AllErrors returns a list of validation violation errors.
    81  func (m RtdsDummyMultiError) AllErrors() []error { return m }
    82  
    83  // RtdsDummyValidationError is the validation error returned by
    84  // RtdsDummy.Validate if the designated constraints aren't met.
    85  type RtdsDummyValidationError struct {
    86  	field  string
    87  	reason string
    88  	cause  error
    89  	key    bool
    90  }
    91  
    92  // Field function returns field value.
    93  func (e RtdsDummyValidationError) Field() string { return e.field }
    94  
    95  // Reason function returns reason value.
    96  func (e RtdsDummyValidationError) Reason() string { return e.reason }
    97  
    98  // Cause function returns cause value.
    99  func (e RtdsDummyValidationError) Cause() error { return e.cause }
   100  
   101  // Key function returns key value.
   102  func (e RtdsDummyValidationError) Key() bool { return e.key }
   103  
   104  // ErrorName returns error name.
   105  func (e RtdsDummyValidationError) ErrorName() string { return "RtdsDummyValidationError" }
   106  
   107  // Error satisfies the builtin error interface
   108  func (e RtdsDummyValidationError) Error() string {
   109  	cause := ""
   110  	if e.cause != nil {
   111  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   112  	}
   113  
   114  	key := ""
   115  	if e.key {
   116  		key = "key for "
   117  	}
   118  
   119  	return fmt.Sprintf(
   120  		"invalid %sRtdsDummy.%s: %s%s",
   121  		key,
   122  		e.field,
   123  		e.reason,
   124  		cause)
   125  }
   126  
   127  var _ error = RtdsDummyValidationError{}
   128  
   129  var _ interface {
   130  	Field() string
   131  	Reason() string
   132  	Key() bool
   133  	Cause() error
   134  	ErrorName() string
   135  } = RtdsDummyValidationError{}
   136  
   137  // Validate checks the field values on Runtime with the rules defined in the
   138  // proto definition for this message. If any rules are violated, the first
   139  // error encountered is returned, or nil if there are no violations.
   140  func (m *Runtime) Validate() error {
   141  	return m.validate(false)
   142  }
   143  
   144  // ValidateAll checks the field values on Runtime with the rules defined in the
   145  // proto definition for this message. If any rules are violated, the result is
   146  // a list of violation errors wrapped in RuntimeMultiError, or nil if none found.
   147  func (m *Runtime) ValidateAll() error {
   148  	return m.validate(true)
   149  }
   150  
   151  func (m *Runtime) validate(all bool) error {
   152  	if m == nil {
   153  		return nil
   154  	}
   155  
   156  	var errors []error
   157  
   158  	if len(m.GetName()) < 1 {
   159  		err := RuntimeValidationError{
   160  			field:  "Name",
   161  			reason: "value length must be at least 1 bytes",
   162  		}
   163  		if !all {
   164  			return err
   165  		}
   166  		errors = append(errors, err)
   167  	}
   168  
   169  	if all {
   170  		switch v := interface{}(m.GetLayer()).(type) {
   171  		case interface{ ValidateAll() error }:
   172  			if err := v.ValidateAll(); err != nil {
   173  				errors = append(errors, RuntimeValidationError{
   174  					field:  "Layer",
   175  					reason: "embedded message failed validation",
   176  					cause:  err,
   177  				})
   178  			}
   179  		case interface{ Validate() error }:
   180  			if err := v.Validate(); err != nil {
   181  				errors = append(errors, RuntimeValidationError{
   182  					field:  "Layer",
   183  					reason: "embedded message failed validation",
   184  					cause:  err,
   185  				})
   186  			}
   187  		}
   188  	} else if v, ok := interface{}(m.GetLayer()).(interface{ Validate() error }); ok {
   189  		if err := v.Validate(); err != nil {
   190  			return RuntimeValidationError{
   191  				field:  "Layer",
   192  				reason: "embedded message failed validation",
   193  				cause:  err,
   194  			}
   195  		}
   196  	}
   197  
   198  	if len(errors) > 0 {
   199  		return RuntimeMultiError(errors)
   200  	}
   201  
   202  	return nil
   203  }
   204  
   205  // RuntimeMultiError is an error wrapping multiple validation errors returned
   206  // by Runtime.ValidateAll() if the designated constraints aren't met.
   207  type RuntimeMultiError []error
   208  
   209  // Error returns a concatenation of all the error messages it wraps.
   210  func (m RuntimeMultiError) Error() string {
   211  	var msgs []string
   212  	for _, err := range m {
   213  		msgs = append(msgs, err.Error())
   214  	}
   215  	return strings.Join(msgs, "; ")
   216  }
   217  
   218  // AllErrors returns a list of validation violation errors.
   219  func (m RuntimeMultiError) AllErrors() []error { return m }
   220  
   221  // RuntimeValidationError is the validation error returned by Runtime.Validate
   222  // if the designated constraints aren't met.
   223  type RuntimeValidationError struct {
   224  	field  string
   225  	reason string
   226  	cause  error
   227  	key    bool
   228  }
   229  
   230  // Field function returns field value.
   231  func (e RuntimeValidationError) Field() string { return e.field }
   232  
   233  // Reason function returns reason value.
   234  func (e RuntimeValidationError) Reason() string { return e.reason }
   235  
   236  // Cause function returns cause value.
   237  func (e RuntimeValidationError) Cause() error { return e.cause }
   238  
   239  // Key function returns key value.
   240  func (e RuntimeValidationError) Key() bool { return e.key }
   241  
   242  // ErrorName returns error name.
   243  func (e RuntimeValidationError) ErrorName() string { return "RuntimeValidationError" }
   244  
   245  // Error satisfies the builtin error interface
   246  func (e RuntimeValidationError) Error() string {
   247  	cause := ""
   248  	if e.cause != nil {
   249  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   250  	}
   251  
   252  	key := ""
   253  	if e.key {
   254  		key = "key for "
   255  	}
   256  
   257  	return fmt.Sprintf(
   258  		"invalid %sRuntime.%s: %s%s",
   259  		key,
   260  		e.field,
   261  		e.reason,
   262  		cause)
   263  }
   264  
   265  var _ error = RuntimeValidationError{}
   266  
   267  var _ interface {
   268  	Field() string
   269  	Reason() string
   270  	Key() bool
   271  	Cause() error
   272  	ErrorName() string
   273  } = RuntimeValidationError{}
   274  

View as plain text