...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/api/envoy/data/dns/v2alpha/dns_table.pb.validate.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/api/envoy/data/dns/v2alpha

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/data/dns/v2alpha/dns_table.proto
     3  
     4  package v2alpha
     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 DnsTable 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 *DnsTable) Validate() error {
    42  	return m.validate(false)
    43  }
    44  
    45  // ValidateAll checks the field values on DnsTable 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 DnsTableMultiError, or nil
    48  // if none found.
    49  func (m *DnsTable) ValidateAll() error {
    50  	return m.validate(true)
    51  }
    52  
    53  func (m *DnsTable) validate(all bool) error {
    54  	if m == nil {
    55  		return nil
    56  	}
    57  
    58  	var errors []error
    59  
    60  	// no validation rules for ExternalRetryCount
    61  
    62  	if len(m.GetVirtualDomains()) < 1 {
    63  		err := DnsTableValidationError{
    64  			field:  "VirtualDomains",
    65  			reason: "value must contain at least 1 item(s)",
    66  		}
    67  		if !all {
    68  			return err
    69  		}
    70  		errors = append(errors, err)
    71  	}
    72  
    73  	for idx, item := range m.GetVirtualDomains() {
    74  		_, _ = idx, item
    75  
    76  		if all {
    77  			switch v := interface{}(item).(type) {
    78  			case interface{ ValidateAll() error }:
    79  				if err := v.ValidateAll(); err != nil {
    80  					errors = append(errors, DnsTableValidationError{
    81  						field:  fmt.Sprintf("VirtualDomains[%v]", idx),
    82  						reason: "embedded message failed validation",
    83  						cause:  err,
    84  					})
    85  				}
    86  			case interface{ Validate() error }:
    87  				if err := v.Validate(); err != nil {
    88  					errors = append(errors, DnsTableValidationError{
    89  						field:  fmt.Sprintf("VirtualDomains[%v]", idx),
    90  						reason: "embedded message failed validation",
    91  						cause:  err,
    92  					})
    93  				}
    94  			}
    95  		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
    96  			if err := v.Validate(); err != nil {
    97  				return DnsTableValidationError{
    98  					field:  fmt.Sprintf("VirtualDomains[%v]", idx),
    99  					reason: "embedded message failed validation",
   100  					cause:  err,
   101  				}
   102  			}
   103  		}
   104  
   105  	}
   106  
   107  	for idx, item := range m.GetKnownSuffixes() {
   108  		_, _ = idx, item
   109  
   110  		if all {
   111  			switch v := interface{}(item).(type) {
   112  			case interface{ ValidateAll() error }:
   113  				if err := v.ValidateAll(); err != nil {
   114  					errors = append(errors, DnsTableValidationError{
   115  						field:  fmt.Sprintf("KnownSuffixes[%v]", idx),
   116  						reason: "embedded message failed validation",
   117  						cause:  err,
   118  					})
   119  				}
   120  			case interface{ Validate() error }:
   121  				if err := v.Validate(); err != nil {
   122  					errors = append(errors, DnsTableValidationError{
   123  						field:  fmt.Sprintf("KnownSuffixes[%v]", idx),
   124  						reason: "embedded message failed validation",
   125  						cause:  err,
   126  					})
   127  				}
   128  			}
   129  		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   130  			if err := v.Validate(); err != nil {
   131  				return DnsTableValidationError{
   132  					field:  fmt.Sprintf("KnownSuffixes[%v]", idx),
   133  					reason: "embedded message failed validation",
   134  					cause:  err,
   135  				}
   136  			}
   137  		}
   138  
   139  	}
   140  
   141  	if len(errors) > 0 {
   142  		return DnsTableMultiError(errors)
   143  	}
   144  
   145  	return nil
   146  }
   147  
   148  // DnsTableMultiError is an error wrapping multiple validation errors returned
   149  // by DnsTable.ValidateAll() if the designated constraints aren't met.
   150  type DnsTableMultiError []error
   151  
   152  // Error returns a concatenation of all the error messages it wraps.
   153  func (m DnsTableMultiError) Error() string {
   154  	var msgs []string
   155  	for _, err := range m {
   156  		msgs = append(msgs, err.Error())
   157  	}
   158  	return strings.Join(msgs, "; ")
   159  }
   160  
   161  // AllErrors returns a list of validation violation errors.
   162  func (m DnsTableMultiError) AllErrors() []error { return m }
   163  
   164  // DnsTableValidationError is the validation error returned by
   165  // DnsTable.Validate if the designated constraints aren't met.
   166  type DnsTableValidationError struct {
   167  	field  string
   168  	reason string
   169  	cause  error
   170  	key    bool
   171  }
   172  
   173  // Field function returns field value.
   174  func (e DnsTableValidationError) Field() string { return e.field }
   175  
   176  // Reason function returns reason value.
   177  func (e DnsTableValidationError) Reason() string { return e.reason }
   178  
   179  // Cause function returns cause value.
   180  func (e DnsTableValidationError) Cause() error { return e.cause }
   181  
   182  // Key function returns key value.
   183  func (e DnsTableValidationError) Key() bool { return e.key }
   184  
   185  // ErrorName returns error name.
   186  func (e DnsTableValidationError) ErrorName() string { return "DnsTableValidationError" }
   187  
   188  // Error satisfies the builtin error interface
   189  func (e DnsTableValidationError) Error() string {
   190  	cause := ""
   191  	if e.cause != nil {
   192  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   193  	}
   194  
   195  	key := ""
   196  	if e.key {
   197  		key = "key for "
   198  	}
   199  
   200  	return fmt.Sprintf(
   201  		"invalid %sDnsTable.%s: %s%s",
   202  		key,
   203  		e.field,
   204  		e.reason,
   205  		cause)
   206  }
   207  
   208  var _ error = DnsTableValidationError{}
   209  
   210  var _ interface {
   211  	Field() string
   212  	Reason() string
   213  	Key() bool
   214  	Cause() error
   215  	ErrorName() string
   216  } = DnsTableValidationError{}
   217  
   218  // Validate checks the field values on DnsTable_AddressList with the rules
   219  // defined in the proto definition for this message. If any rules are
   220  // violated, the first error encountered is returned, or nil if there are no violations.
   221  func (m *DnsTable_AddressList) Validate() error {
   222  	return m.validate(false)
   223  }
   224  
   225  // ValidateAll checks the field values on DnsTable_AddressList with the rules
   226  // defined in the proto definition for this message. If any rules are
   227  // violated, the result is a list of violation errors wrapped in
   228  // DnsTable_AddressListMultiError, or nil if none found.
   229  func (m *DnsTable_AddressList) ValidateAll() error {
   230  	return m.validate(true)
   231  }
   232  
   233  func (m *DnsTable_AddressList) validate(all bool) error {
   234  	if m == nil {
   235  		return nil
   236  	}
   237  
   238  	var errors []error
   239  
   240  	if len(m.GetAddress()) < 1 {
   241  		err := DnsTable_AddressListValidationError{
   242  			field:  "Address",
   243  			reason: "value must contain at least 1 item(s)",
   244  		}
   245  		if !all {
   246  			return err
   247  		}
   248  		errors = append(errors, err)
   249  	}
   250  
   251  	for idx, item := range m.GetAddress() {
   252  		_, _ = idx, item
   253  
   254  		if utf8.RuneCountInString(item) < 3 {
   255  			err := DnsTable_AddressListValidationError{
   256  				field:  fmt.Sprintf("Address[%v]", idx),
   257  				reason: "value length must be at least 3 runes",
   258  			}
   259  			if !all {
   260  				return err
   261  			}
   262  			errors = append(errors, err)
   263  		}
   264  
   265  	}
   266  
   267  	if len(errors) > 0 {
   268  		return DnsTable_AddressListMultiError(errors)
   269  	}
   270  
   271  	return nil
   272  }
   273  
   274  // DnsTable_AddressListMultiError is an error wrapping multiple validation
   275  // errors returned by DnsTable_AddressList.ValidateAll() if the designated
   276  // constraints aren't met.
   277  type DnsTable_AddressListMultiError []error
   278  
   279  // Error returns a concatenation of all the error messages it wraps.
   280  func (m DnsTable_AddressListMultiError) Error() string {
   281  	var msgs []string
   282  	for _, err := range m {
   283  		msgs = append(msgs, err.Error())
   284  	}
   285  	return strings.Join(msgs, "; ")
   286  }
   287  
   288  // AllErrors returns a list of validation violation errors.
   289  func (m DnsTable_AddressListMultiError) AllErrors() []error { return m }
   290  
   291  // DnsTable_AddressListValidationError is the validation error returned by
   292  // DnsTable_AddressList.Validate if the designated constraints aren't met.
   293  type DnsTable_AddressListValidationError struct {
   294  	field  string
   295  	reason string
   296  	cause  error
   297  	key    bool
   298  }
   299  
   300  // Field function returns field value.
   301  func (e DnsTable_AddressListValidationError) Field() string { return e.field }
   302  
   303  // Reason function returns reason value.
   304  func (e DnsTable_AddressListValidationError) Reason() string { return e.reason }
   305  
   306  // Cause function returns cause value.
   307  func (e DnsTable_AddressListValidationError) Cause() error { return e.cause }
   308  
   309  // Key function returns key value.
   310  func (e DnsTable_AddressListValidationError) Key() bool { return e.key }
   311  
   312  // ErrorName returns error name.
   313  func (e DnsTable_AddressListValidationError) ErrorName() string {
   314  	return "DnsTable_AddressListValidationError"
   315  }
   316  
   317  // Error satisfies the builtin error interface
   318  func (e DnsTable_AddressListValidationError) Error() string {
   319  	cause := ""
   320  	if e.cause != nil {
   321  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   322  	}
   323  
   324  	key := ""
   325  	if e.key {
   326  		key = "key for "
   327  	}
   328  
   329  	return fmt.Sprintf(
   330  		"invalid %sDnsTable_AddressList.%s: %s%s",
   331  		key,
   332  		e.field,
   333  		e.reason,
   334  		cause)
   335  }
   336  
   337  var _ error = DnsTable_AddressListValidationError{}
   338  
   339  var _ interface {
   340  	Field() string
   341  	Reason() string
   342  	Key() bool
   343  	Cause() error
   344  	ErrorName() string
   345  } = DnsTable_AddressListValidationError{}
   346  
   347  // Validate checks the field values on DnsTable_DnsEndpoint with the rules
   348  // defined in the proto definition for this message. If any rules are
   349  // violated, the first error encountered is returned, or nil if there are no violations.
   350  func (m *DnsTable_DnsEndpoint) Validate() error {
   351  	return m.validate(false)
   352  }
   353  
   354  // ValidateAll checks the field values on DnsTable_DnsEndpoint with the rules
   355  // defined in the proto definition for this message. If any rules are
   356  // violated, the result is a list of violation errors wrapped in
   357  // DnsTable_DnsEndpointMultiError, or nil if none found.
   358  func (m *DnsTable_DnsEndpoint) ValidateAll() error {
   359  	return m.validate(true)
   360  }
   361  
   362  func (m *DnsTable_DnsEndpoint) validate(all bool) error {
   363  	if m == nil {
   364  		return nil
   365  	}
   366  
   367  	var errors []error
   368  
   369  	oneofEndpointConfigPresent := false
   370  	switch v := m.EndpointConfig.(type) {
   371  	case *DnsTable_DnsEndpoint_AddressList:
   372  		if v == nil {
   373  			err := DnsTable_DnsEndpointValidationError{
   374  				field:  "EndpointConfig",
   375  				reason: "oneof value cannot be a typed-nil",
   376  			}
   377  			if !all {
   378  				return err
   379  			}
   380  			errors = append(errors, err)
   381  		}
   382  		oneofEndpointConfigPresent = true
   383  
   384  		if all {
   385  			switch v := interface{}(m.GetAddressList()).(type) {
   386  			case interface{ ValidateAll() error }:
   387  				if err := v.ValidateAll(); err != nil {
   388  					errors = append(errors, DnsTable_DnsEndpointValidationError{
   389  						field:  "AddressList",
   390  						reason: "embedded message failed validation",
   391  						cause:  err,
   392  					})
   393  				}
   394  			case interface{ Validate() error }:
   395  				if err := v.Validate(); err != nil {
   396  					errors = append(errors, DnsTable_DnsEndpointValidationError{
   397  						field:  "AddressList",
   398  						reason: "embedded message failed validation",
   399  						cause:  err,
   400  					})
   401  				}
   402  			}
   403  		} else if v, ok := interface{}(m.GetAddressList()).(interface{ Validate() error }); ok {
   404  			if err := v.Validate(); err != nil {
   405  				return DnsTable_DnsEndpointValidationError{
   406  					field:  "AddressList",
   407  					reason: "embedded message failed validation",
   408  					cause:  err,
   409  				}
   410  			}
   411  		}
   412  
   413  	default:
   414  		_ = v // ensures v is used
   415  	}
   416  	if !oneofEndpointConfigPresent {
   417  		err := DnsTable_DnsEndpointValidationError{
   418  			field:  "EndpointConfig",
   419  			reason: "value is required",
   420  		}
   421  		if !all {
   422  			return err
   423  		}
   424  		errors = append(errors, err)
   425  	}
   426  
   427  	if len(errors) > 0 {
   428  		return DnsTable_DnsEndpointMultiError(errors)
   429  	}
   430  
   431  	return nil
   432  }
   433  
   434  // DnsTable_DnsEndpointMultiError is an error wrapping multiple validation
   435  // errors returned by DnsTable_DnsEndpoint.ValidateAll() if the designated
   436  // constraints aren't met.
   437  type DnsTable_DnsEndpointMultiError []error
   438  
   439  // Error returns a concatenation of all the error messages it wraps.
   440  func (m DnsTable_DnsEndpointMultiError) Error() string {
   441  	var msgs []string
   442  	for _, err := range m {
   443  		msgs = append(msgs, err.Error())
   444  	}
   445  	return strings.Join(msgs, "; ")
   446  }
   447  
   448  // AllErrors returns a list of validation violation errors.
   449  func (m DnsTable_DnsEndpointMultiError) AllErrors() []error { return m }
   450  
   451  // DnsTable_DnsEndpointValidationError is the validation error returned by
   452  // DnsTable_DnsEndpoint.Validate if the designated constraints aren't met.
   453  type DnsTable_DnsEndpointValidationError struct {
   454  	field  string
   455  	reason string
   456  	cause  error
   457  	key    bool
   458  }
   459  
   460  // Field function returns field value.
   461  func (e DnsTable_DnsEndpointValidationError) Field() string { return e.field }
   462  
   463  // Reason function returns reason value.
   464  func (e DnsTable_DnsEndpointValidationError) Reason() string { return e.reason }
   465  
   466  // Cause function returns cause value.
   467  func (e DnsTable_DnsEndpointValidationError) Cause() error { return e.cause }
   468  
   469  // Key function returns key value.
   470  func (e DnsTable_DnsEndpointValidationError) Key() bool { return e.key }
   471  
   472  // ErrorName returns error name.
   473  func (e DnsTable_DnsEndpointValidationError) ErrorName() string {
   474  	return "DnsTable_DnsEndpointValidationError"
   475  }
   476  
   477  // Error satisfies the builtin error interface
   478  func (e DnsTable_DnsEndpointValidationError) Error() string {
   479  	cause := ""
   480  	if e.cause != nil {
   481  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   482  	}
   483  
   484  	key := ""
   485  	if e.key {
   486  		key = "key for "
   487  	}
   488  
   489  	return fmt.Sprintf(
   490  		"invalid %sDnsTable_DnsEndpoint.%s: %s%s",
   491  		key,
   492  		e.field,
   493  		e.reason,
   494  		cause)
   495  }
   496  
   497  var _ error = DnsTable_DnsEndpointValidationError{}
   498  
   499  var _ interface {
   500  	Field() string
   501  	Reason() string
   502  	Key() bool
   503  	Cause() error
   504  	ErrorName() string
   505  } = DnsTable_DnsEndpointValidationError{}
   506  
   507  // Validate checks the field values on DnsTable_DnsVirtualDomain with the rules
   508  // defined in the proto definition for this message. If any rules are
   509  // violated, the first error encountered is returned, or nil if there are no violations.
   510  func (m *DnsTable_DnsVirtualDomain) Validate() error {
   511  	return m.validate(false)
   512  }
   513  
   514  // ValidateAll checks the field values on DnsTable_DnsVirtualDomain with the
   515  // rules defined in the proto definition for this message. If any rules are
   516  // violated, the result is a list of violation errors wrapped in
   517  // DnsTable_DnsVirtualDomainMultiError, or nil if none found.
   518  func (m *DnsTable_DnsVirtualDomain) ValidateAll() error {
   519  	return m.validate(true)
   520  }
   521  
   522  func (m *DnsTable_DnsVirtualDomain) validate(all bool) error {
   523  	if m == nil {
   524  		return nil
   525  	}
   526  
   527  	var errors []error
   528  
   529  	if utf8.RuneCountInString(m.GetName()) < 2 {
   530  		err := DnsTable_DnsVirtualDomainValidationError{
   531  			field:  "Name",
   532  			reason: "value length must be at least 2 runes",
   533  		}
   534  		if !all {
   535  			return err
   536  		}
   537  		errors = append(errors, err)
   538  	}
   539  
   540  	if !_DnsTable_DnsVirtualDomain_Name_Pattern.MatchString(m.GetName()) {
   541  		err := DnsTable_DnsVirtualDomainValidationError{
   542  			field:  "Name",
   543  			reason: "value does not match regex pattern \"^:?[0-9a-zA-Z!#$%&'*+-.^_|~`]+$\"",
   544  		}
   545  		if !all {
   546  			return err
   547  		}
   548  		errors = append(errors, err)
   549  	}
   550  
   551  	if all {
   552  		switch v := interface{}(m.GetEndpoint()).(type) {
   553  		case interface{ ValidateAll() error }:
   554  			if err := v.ValidateAll(); err != nil {
   555  				errors = append(errors, DnsTable_DnsVirtualDomainValidationError{
   556  					field:  "Endpoint",
   557  					reason: "embedded message failed validation",
   558  					cause:  err,
   559  				})
   560  			}
   561  		case interface{ Validate() error }:
   562  			if err := v.Validate(); err != nil {
   563  				errors = append(errors, DnsTable_DnsVirtualDomainValidationError{
   564  					field:  "Endpoint",
   565  					reason: "embedded message failed validation",
   566  					cause:  err,
   567  				})
   568  			}
   569  		}
   570  	} else if v, ok := interface{}(m.GetEndpoint()).(interface{ Validate() error }); ok {
   571  		if err := v.Validate(); err != nil {
   572  			return DnsTable_DnsVirtualDomainValidationError{
   573  				field:  "Endpoint",
   574  				reason: "embedded message failed validation",
   575  				cause:  err,
   576  			}
   577  		}
   578  	}
   579  
   580  	if d := m.GetAnswerTtl(); d != nil {
   581  		dur, err := d.AsDuration(), d.CheckValid()
   582  		if err != nil {
   583  			err = DnsTable_DnsVirtualDomainValidationError{
   584  				field:  "AnswerTtl",
   585  				reason: "value is not a valid duration",
   586  				cause:  err,
   587  			}
   588  			if !all {
   589  				return err
   590  			}
   591  			errors = append(errors, err)
   592  		} else {
   593  
   594  			gt := time.Duration(0*time.Second + 0*time.Nanosecond)
   595  
   596  			if dur <= gt {
   597  				err := DnsTable_DnsVirtualDomainValidationError{
   598  					field:  "AnswerTtl",
   599  					reason: "value must be greater than 0s",
   600  				}
   601  				if !all {
   602  					return err
   603  				}
   604  				errors = append(errors, err)
   605  			}
   606  
   607  		}
   608  	}
   609  
   610  	if len(errors) > 0 {
   611  		return DnsTable_DnsVirtualDomainMultiError(errors)
   612  	}
   613  
   614  	return nil
   615  }
   616  
   617  // DnsTable_DnsVirtualDomainMultiError is an error wrapping multiple validation
   618  // errors returned by DnsTable_DnsVirtualDomain.ValidateAll() if the
   619  // designated constraints aren't met.
   620  type DnsTable_DnsVirtualDomainMultiError []error
   621  
   622  // Error returns a concatenation of all the error messages it wraps.
   623  func (m DnsTable_DnsVirtualDomainMultiError) Error() string {
   624  	var msgs []string
   625  	for _, err := range m {
   626  		msgs = append(msgs, err.Error())
   627  	}
   628  	return strings.Join(msgs, "; ")
   629  }
   630  
   631  // AllErrors returns a list of validation violation errors.
   632  func (m DnsTable_DnsVirtualDomainMultiError) AllErrors() []error { return m }
   633  
   634  // DnsTable_DnsVirtualDomainValidationError is the validation error returned by
   635  // DnsTable_DnsVirtualDomain.Validate if the designated constraints aren't met.
   636  type DnsTable_DnsVirtualDomainValidationError struct {
   637  	field  string
   638  	reason string
   639  	cause  error
   640  	key    bool
   641  }
   642  
   643  // Field function returns field value.
   644  func (e DnsTable_DnsVirtualDomainValidationError) Field() string { return e.field }
   645  
   646  // Reason function returns reason value.
   647  func (e DnsTable_DnsVirtualDomainValidationError) Reason() string { return e.reason }
   648  
   649  // Cause function returns cause value.
   650  func (e DnsTable_DnsVirtualDomainValidationError) Cause() error { return e.cause }
   651  
   652  // Key function returns key value.
   653  func (e DnsTable_DnsVirtualDomainValidationError) Key() bool { return e.key }
   654  
   655  // ErrorName returns error name.
   656  func (e DnsTable_DnsVirtualDomainValidationError) ErrorName() string {
   657  	return "DnsTable_DnsVirtualDomainValidationError"
   658  }
   659  
   660  // Error satisfies the builtin error interface
   661  func (e DnsTable_DnsVirtualDomainValidationError) Error() string {
   662  	cause := ""
   663  	if e.cause != nil {
   664  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   665  	}
   666  
   667  	key := ""
   668  	if e.key {
   669  		key = "key for "
   670  	}
   671  
   672  	return fmt.Sprintf(
   673  		"invalid %sDnsTable_DnsVirtualDomain.%s: %s%s",
   674  		key,
   675  		e.field,
   676  		e.reason,
   677  		cause)
   678  }
   679  
   680  var _ error = DnsTable_DnsVirtualDomainValidationError{}
   681  
   682  var _ interface {
   683  	Field() string
   684  	Reason() string
   685  	Key() bool
   686  	Cause() error
   687  	ErrorName() string
   688  } = DnsTable_DnsVirtualDomainValidationError{}
   689  
   690  var _DnsTable_DnsVirtualDomain_Name_Pattern = regexp.MustCompile("^:?[0-9a-zA-Z!#$%&'*+-.^_|~`]+$")
   691  

View as plain text