...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/health_checker/redis/v2/redis.pb.validate.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/health_checker/redis/v2

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

View as plain text