gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/go-control-plane/envoy/data/dns/v2alpha/dns_table.pb.validate.go (about)

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/data/dns/v2alpha/dns_table.proto
     3  
     4  package envoy_data_dns_v2alpha
     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 DnsTable with the rules defined in the
    37  // proto definition for this message. If any rules are violated, an error is returned.
    38  func (m *DnsTable) Validate() error {
    39  	if m == nil {
    40  		return nil
    41  	}
    42  
    43  	// no validation rules for ExternalRetryCount
    44  
    45  	if len(m.GetVirtualDomains()) < 1 {
    46  		return DnsTableValidationError{
    47  			field:  "VirtualDomains",
    48  			reason: "value must contain at least 1 item(s)",
    49  		}
    50  	}
    51  
    52  	for idx, item := range m.GetVirtualDomains() {
    53  		_, _ = idx, item
    54  
    55  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
    56  			if err := v.Validate(); err != nil {
    57  				return DnsTableValidationError{
    58  					field:  fmt.Sprintf("VirtualDomains[%v]", idx),
    59  					reason: "embedded message failed validation",
    60  					cause:  err,
    61  				}
    62  			}
    63  		}
    64  
    65  	}
    66  
    67  	for idx, item := range m.GetKnownSuffixes() {
    68  		_, _ = idx, item
    69  
    70  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
    71  			if err := v.Validate(); err != nil {
    72  				return DnsTableValidationError{
    73  					field:  fmt.Sprintf("KnownSuffixes[%v]", idx),
    74  					reason: "embedded message failed validation",
    75  					cause:  err,
    76  				}
    77  			}
    78  		}
    79  
    80  	}
    81  
    82  	return nil
    83  }
    84  
    85  // DnsTableValidationError is the validation error returned by
    86  // DnsTable.Validate if the designated constraints aren't met.
    87  type DnsTableValidationError struct {
    88  	field  string
    89  	reason string
    90  	cause  error
    91  	key    bool
    92  }
    93  
    94  // Field function returns field value.
    95  func (e DnsTableValidationError) Field() string { return e.field }
    96  
    97  // Reason function returns reason value.
    98  func (e DnsTableValidationError) Reason() string { return e.reason }
    99  
   100  // Cause function returns cause value.
   101  func (e DnsTableValidationError) Cause() error { return e.cause }
   102  
   103  // Key function returns key value.
   104  func (e DnsTableValidationError) Key() bool { return e.key }
   105  
   106  // ErrorName returns error name.
   107  func (e DnsTableValidationError) ErrorName() string { return "DnsTableValidationError" }
   108  
   109  // Error satisfies the builtin error interface
   110  func (e DnsTableValidationError) 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 %sDnsTable.%s: %s%s",
   123  		key,
   124  		e.field,
   125  		e.reason,
   126  		cause)
   127  }
   128  
   129  var _ error = DnsTableValidationError{}
   130  
   131  var _ interface {
   132  	Field() string
   133  	Reason() string
   134  	Key() bool
   135  	Cause() error
   136  	ErrorName() string
   137  } = DnsTableValidationError{}
   138  
   139  // Validate checks the field values on DnsTable_AddressList 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 *DnsTable_AddressList) Validate() error {
   143  	if m == nil {
   144  		return nil
   145  	}
   146  
   147  	if len(m.GetAddress()) < 1 {
   148  		return DnsTable_AddressListValidationError{
   149  			field:  "Address",
   150  			reason: "value must contain at least 1 item(s)",
   151  		}
   152  	}
   153  
   154  	for idx, item := range m.GetAddress() {
   155  		_, _ = idx, item
   156  
   157  		if utf8.RuneCountInString(item) < 3 {
   158  			return DnsTable_AddressListValidationError{
   159  				field:  fmt.Sprintf("Address[%v]", idx),
   160  				reason: "value length must be at least 3 runes",
   161  			}
   162  		}
   163  
   164  	}
   165  
   166  	return nil
   167  }
   168  
   169  // DnsTable_AddressListValidationError is the validation error returned by
   170  // DnsTable_AddressList.Validate if the designated constraints aren't met.
   171  type DnsTable_AddressListValidationError struct {
   172  	field  string
   173  	reason string
   174  	cause  error
   175  	key    bool
   176  }
   177  
   178  // Field function returns field value.
   179  func (e DnsTable_AddressListValidationError) Field() string { return e.field }
   180  
   181  // Reason function returns reason value.
   182  func (e DnsTable_AddressListValidationError) Reason() string { return e.reason }
   183  
   184  // Cause function returns cause value.
   185  func (e DnsTable_AddressListValidationError) Cause() error { return e.cause }
   186  
   187  // Key function returns key value.
   188  func (e DnsTable_AddressListValidationError) Key() bool { return e.key }
   189  
   190  // ErrorName returns error name.
   191  func (e DnsTable_AddressListValidationError) ErrorName() string {
   192  	return "DnsTable_AddressListValidationError"
   193  }
   194  
   195  // Error satisfies the builtin error interface
   196  func (e DnsTable_AddressListValidationError) Error() string {
   197  	cause := ""
   198  	if e.cause != nil {
   199  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   200  	}
   201  
   202  	key := ""
   203  	if e.key {
   204  		key = "key for "
   205  	}
   206  
   207  	return fmt.Sprintf(
   208  		"invalid %sDnsTable_AddressList.%s: %s%s",
   209  		key,
   210  		e.field,
   211  		e.reason,
   212  		cause)
   213  }
   214  
   215  var _ error = DnsTable_AddressListValidationError{}
   216  
   217  var _ interface {
   218  	Field() string
   219  	Reason() string
   220  	Key() bool
   221  	Cause() error
   222  	ErrorName() string
   223  } = DnsTable_AddressListValidationError{}
   224  
   225  // Validate checks the field values on DnsTable_DnsEndpoint with the rules
   226  // defined in the proto definition for this message. If any rules are
   227  // violated, an error is returned.
   228  func (m *DnsTable_DnsEndpoint) Validate() error {
   229  	if m == nil {
   230  		return nil
   231  	}
   232  
   233  	switch m.EndpointConfig.(type) {
   234  
   235  	case *DnsTable_DnsEndpoint_AddressList:
   236  
   237  		if v, ok := interface{}(m.GetAddressList()).(interface{ Validate() error }); ok {
   238  			if err := v.Validate(); err != nil {
   239  				return DnsTable_DnsEndpointValidationError{
   240  					field:  "AddressList",
   241  					reason: "embedded message failed validation",
   242  					cause:  err,
   243  				}
   244  			}
   245  		}
   246  
   247  	default:
   248  		return DnsTable_DnsEndpointValidationError{
   249  			field:  "EndpointConfig",
   250  			reason: "value is required",
   251  		}
   252  
   253  	}
   254  
   255  	return nil
   256  }
   257  
   258  // DnsTable_DnsEndpointValidationError is the validation error returned by
   259  // DnsTable_DnsEndpoint.Validate if the designated constraints aren't met.
   260  type DnsTable_DnsEndpointValidationError struct {
   261  	field  string
   262  	reason string
   263  	cause  error
   264  	key    bool
   265  }
   266  
   267  // Field function returns field value.
   268  func (e DnsTable_DnsEndpointValidationError) Field() string { return e.field }
   269  
   270  // Reason function returns reason value.
   271  func (e DnsTable_DnsEndpointValidationError) Reason() string { return e.reason }
   272  
   273  // Cause function returns cause value.
   274  func (e DnsTable_DnsEndpointValidationError) Cause() error { return e.cause }
   275  
   276  // Key function returns key value.
   277  func (e DnsTable_DnsEndpointValidationError) Key() bool { return e.key }
   278  
   279  // ErrorName returns error name.
   280  func (e DnsTable_DnsEndpointValidationError) ErrorName() string {
   281  	return "DnsTable_DnsEndpointValidationError"
   282  }
   283  
   284  // Error satisfies the builtin error interface
   285  func (e DnsTable_DnsEndpointValidationError) Error() string {
   286  	cause := ""
   287  	if e.cause != nil {
   288  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   289  	}
   290  
   291  	key := ""
   292  	if e.key {
   293  		key = "key for "
   294  	}
   295  
   296  	return fmt.Sprintf(
   297  		"invalid %sDnsTable_DnsEndpoint.%s: %s%s",
   298  		key,
   299  		e.field,
   300  		e.reason,
   301  		cause)
   302  }
   303  
   304  var _ error = DnsTable_DnsEndpointValidationError{}
   305  
   306  var _ interface {
   307  	Field() string
   308  	Reason() string
   309  	Key() bool
   310  	Cause() error
   311  	ErrorName() string
   312  } = DnsTable_DnsEndpointValidationError{}
   313  
   314  // Validate checks the field values on DnsTable_DnsVirtualDomain with the rules
   315  // defined in the proto definition for this message. If any rules are
   316  // violated, an error is returned.
   317  func (m *DnsTable_DnsVirtualDomain) Validate() error {
   318  	if m == nil {
   319  		return nil
   320  	}
   321  
   322  	if utf8.RuneCountInString(m.GetName()) < 2 {
   323  		return DnsTable_DnsVirtualDomainValidationError{
   324  			field:  "Name",
   325  			reason: "value length must be at least 2 runes",
   326  		}
   327  	}
   328  
   329  	if !_DnsTable_DnsVirtualDomain_Name_Pattern.MatchString(m.GetName()) {
   330  		return DnsTable_DnsVirtualDomainValidationError{
   331  			field:  "Name",
   332  			reason: "value does not match regex pattern \"^:?[0-9a-zA-Z!#$%&'*+-.^_|~`]+$\"",
   333  		}
   334  	}
   335  
   336  	if v, ok := interface{}(m.GetEndpoint()).(interface{ Validate() error }); ok {
   337  		if err := v.Validate(); err != nil {
   338  			return DnsTable_DnsVirtualDomainValidationError{
   339  				field:  "Endpoint",
   340  				reason: "embedded message failed validation",
   341  				cause:  err,
   342  			}
   343  		}
   344  	}
   345  
   346  	if d := m.GetAnswerTtl(); d != nil {
   347  		dur, err := d.AsDuration(), d.CheckValid()
   348  		if err != nil {
   349  			return DnsTable_DnsVirtualDomainValidationError{
   350  				field:  "AnswerTtl",
   351  				reason: "value is not a valid duration",
   352  				cause:  err,
   353  			}
   354  		}
   355  
   356  		gt := time.Duration(0*time.Second + 0*time.Nanosecond)
   357  
   358  		if dur <= gt {
   359  			return DnsTable_DnsVirtualDomainValidationError{
   360  				field:  "AnswerTtl",
   361  				reason: "value must be greater than 0s",
   362  			}
   363  		}
   364  
   365  	}
   366  
   367  	return nil
   368  }
   369  
   370  // DnsTable_DnsVirtualDomainValidationError is the validation error returned by
   371  // DnsTable_DnsVirtualDomain.Validate if the designated constraints aren't met.
   372  type DnsTable_DnsVirtualDomainValidationError struct {
   373  	field  string
   374  	reason string
   375  	cause  error
   376  	key    bool
   377  }
   378  
   379  // Field function returns field value.
   380  func (e DnsTable_DnsVirtualDomainValidationError) Field() string { return e.field }
   381  
   382  // Reason function returns reason value.
   383  func (e DnsTable_DnsVirtualDomainValidationError) Reason() string { return e.reason }
   384  
   385  // Cause function returns cause value.
   386  func (e DnsTable_DnsVirtualDomainValidationError) Cause() error { return e.cause }
   387  
   388  // Key function returns key value.
   389  func (e DnsTable_DnsVirtualDomainValidationError) Key() bool { return e.key }
   390  
   391  // ErrorName returns error name.
   392  func (e DnsTable_DnsVirtualDomainValidationError) ErrorName() string {
   393  	return "DnsTable_DnsVirtualDomainValidationError"
   394  }
   395  
   396  // Error satisfies the builtin error interface
   397  func (e DnsTable_DnsVirtualDomainValidationError) Error() string {
   398  	cause := ""
   399  	if e.cause != nil {
   400  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   401  	}
   402  
   403  	key := ""
   404  	if e.key {
   405  		key = "key for "
   406  	}
   407  
   408  	return fmt.Sprintf(
   409  		"invalid %sDnsTable_DnsVirtualDomain.%s: %s%s",
   410  		key,
   411  		e.field,
   412  		e.reason,
   413  		cause)
   414  }
   415  
   416  var _ error = DnsTable_DnsVirtualDomainValidationError{}
   417  
   418  var _ interface {
   419  	Field() string
   420  	Reason() string
   421  	Key() bool
   422  	Cause() error
   423  	ErrorName() string
   424  } = DnsTable_DnsVirtualDomainValidationError{}
   425  
   426  var _DnsTable_DnsVirtualDomain_Name_Pattern = regexp.MustCompile("^:?[0-9a-zA-Z!#$%&'*+-.^_|~`]+$")