...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/api/envoy/annotations/resource.pb.validate.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/api/envoy/annotations

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/annotations/resource.proto
     3  
     4  package annotations
     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 ResourceAnnotation with the rules
    39  // defined in the proto definition for this message. If any rules are
    40  // violated, the first error encountered is returned, or nil if there are no violations.
    41  func (m *ResourceAnnotation) Validate() error {
    42  	return m.validate(false)
    43  }
    44  
    45  // ValidateAll checks the field values on ResourceAnnotation with the rules
    46  // defined in the proto definition for this message. If any rules are
    47  // violated, the result is a list of violation errors wrapped in
    48  // ResourceAnnotationMultiError, or nil if none found.
    49  func (m *ResourceAnnotation) ValidateAll() error {
    50  	return m.validate(true)
    51  }
    52  
    53  func (m *ResourceAnnotation) validate(all bool) error {
    54  	if m == nil {
    55  		return nil
    56  	}
    57  
    58  	var errors []error
    59  
    60  	// no validation rules for Type
    61  
    62  	if len(errors) > 0 {
    63  		return ResourceAnnotationMultiError(errors)
    64  	}
    65  
    66  	return nil
    67  }
    68  
    69  // ResourceAnnotationMultiError is an error wrapping multiple validation errors
    70  // returned by ResourceAnnotation.ValidateAll() if the designated constraints
    71  // aren't met.
    72  type ResourceAnnotationMultiError []error
    73  
    74  // Error returns a concatenation of all the error messages it wraps.
    75  func (m ResourceAnnotationMultiError) Error() string {
    76  	var msgs []string
    77  	for _, err := range m {
    78  		msgs = append(msgs, err.Error())
    79  	}
    80  	return strings.Join(msgs, "; ")
    81  }
    82  
    83  // AllErrors returns a list of validation violation errors.
    84  func (m ResourceAnnotationMultiError) AllErrors() []error { return m }
    85  
    86  // ResourceAnnotationValidationError is the validation error returned by
    87  // ResourceAnnotation.Validate if the designated constraints aren't met.
    88  type ResourceAnnotationValidationError struct {
    89  	field  string
    90  	reason string
    91  	cause  error
    92  	key    bool
    93  }
    94  
    95  // Field function returns field value.
    96  func (e ResourceAnnotationValidationError) Field() string { return e.field }
    97  
    98  // Reason function returns reason value.
    99  func (e ResourceAnnotationValidationError) Reason() string { return e.reason }
   100  
   101  // Cause function returns cause value.
   102  func (e ResourceAnnotationValidationError) Cause() error { return e.cause }
   103  
   104  // Key function returns key value.
   105  func (e ResourceAnnotationValidationError) Key() bool { return e.key }
   106  
   107  // ErrorName returns error name.
   108  func (e ResourceAnnotationValidationError) ErrorName() string {
   109  	return "ResourceAnnotationValidationError"
   110  }
   111  
   112  // Error satisfies the builtin error interface
   113  func (e ResourceAnnotationValidationError) Error() string {
   114  	cause := ""
   115  	if e.cause != nil {
   116  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   117  	}
   118  
   119  	key := ""
   120  	if e.key {
   121  		key = "key for "
   122  	}
   123  
   124  	return fmt.Sprintf(
   125  		"invalid %sResourceAnnotation.%s: %s%s",
   126  		key,
   127  		e.field,
   128  		e.reason,
   129  		cause)
   130  }
   131  
   132  var _ error = ResourceAnnotationValidationError{}
   133  
   134  var _ interface {
   135  	Field() string
   136  	Reason() string
   137  	Key() bool
   138  	Cause() error
   139  	ErrorName() string
   140  } = ResourceAnnotationValidationError{}
   141  

View as plain text