go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/cv/settings/listener/settings.pb.validate.go (about)

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: go.chromium.org/luci/cv/settings/listener/settings.proto
     3  
     4  package listenerpb
     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 Settings 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 *Settings) Validate() error {
    42  	return m.validate(false)
    43  }
    44  
    45  // ValidateAll checks the field values on Settings 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 SettingsMultiError, or nil
    48  // if none found.
    49  func (m *Settings) ValidateAll() error {
    50  	return m.validate(true)
    51  }
    52  
    53  func (m *Settings) validate(all bool) error {
    54  	if m == nil {
    55  		return nil
    56  	}
    57  
    58  	var errors []error
    59  
    60  	for idx, item := range m.GetGerritSubscriptions() {
    61  		_, _ = idx, item
    62  
    63  		if all {
    64  			switch v := interface{}(item).(type) {
    65  			case interface{ ValidateAll() error }:
    66  				if err := v.ValidateAll(); err != nil {
    67  					errors = append(errors, SettingsValidationError{
    68  						field:  fmt.Sprintf("GerritSubscriptions[%v]", idx),
    69  						reason: "embedded message failed validation",
    70  						cause:  err,
    71  					})
    72  				}
    73  			case interface{ Validate() error }:
    74  				if err := v.Validate(); err != nil {
    75  					errors = append(errors, SettingsValidationError{
    76  						field:  fmt.Sprintf("GerritSubscriptions[%v]", idx),
    77  						reason: "embedded message failed validation",
    78  						cause:  err,
    79  					})
    80  				}
    81  			}
    82  		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
    83  			if err := v.Validate(); err != nil {
    84  				return SettingsValidationError{
    85  					field:  fmt.Sprintf("GerritSubscriptions[%v]", idx),
    86  					reason: "embedded message failed validation",
    87  					cause:  err,
    88  				}
    89  			}
    90  		}
    91  
    92  	}
    93  
    94  	if len(errors) > 0 {
    95  		return SettingsMultiError(errors)
    96  	}
    97  
    98  	return nil
    99  }
   100  
   101  // SettingsMultiError is an error wrapping multiple validation errors returned
   102  // by Settings.ValidateAll() if the designated constraints aren't met.
   103  type SettingsMultiError []error
   104  
   105  // Error returns a concatenation of all the error messages it wraps.
   106  func (m SettingsMultiError) Error() string {
   107  	var msgs []string
   108  	for _, err := range m {
   109  		msgs = append(msgs, err.Error())
   110  	}
   111  	return strings.Join(msgs, "; ")
   112  }
   113  
   114  // AllErrors returns a list of validation violation errors.
   115  func (m SettingsMultiError) AllErrors() []error { return m }
   116  
   117  // SettingsValidationError is the validation error returned by
   118  // Settings.Validate if the designated constraints aren't met.
   119  type SettingsValidationError struct {
   120  	field  string
   121  	reason string
   122  	cause  error
   123  	key    bool
   124  }
   125  
   126  // Field function returns field value.
   127  func (e SettingsValidationError) Field() string { return e.field }
   128  
   129  // Reason function returns reason value.
   130  func (e SettingsValidationError) Reason() string { return e.reason }
   131  
   132  // Cause function returns cause value.
   133  func (e SettingsValidationError) Cause() error { return e.cause }
   134  
   135  // Key function returns key value.
   136  func (e SettingsValidationError) Key() bool { return e.key }
   137  
   138  // ErrorName returns error name.
   139  func (e SettingsValidationError) ErrorName() string { return "SettingsValidationError" }
   140  
   141  // Error satisfies the builtin error interface
   142  func (e SettingsValidationError) Error() string {
   143  	cause := ""
   144  	if e.cause != nil {
   145  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   146  	}
   147  
   148  	key := ""
   149  	if e.key {
   150  		key = "key for "
   151  	}
   152  
   153  	return fmt.Sprintf(
   154  		"invalid %sSettings.%s: %s%s",
   155  		key,
   156  		e.field,
   157  		e.reason,
   158  		cause)
   159  }
   160  
   161  var _ error = SettingsValidationError{}
   162  
   163  var _ interface {
   164  	Field() string
   165  	Reason() string
   166  	Key() bool
   167  	Cause() error
   168  	ErrorName() string
   169  } = SettingsValidationError{}
   170  
   171  // Validate checks the field values on Settings_ReceiveSettings with the rules
   172  // defined in the proto definition for this message. If any rules are
   173  // violated, the first error encountered is returned, or nil if there are no violations.
   174  func (m *Settings_ReceiveSettings) Validate() error {
   175  	return m.validate(false)
   176  }
   177  
   178  // ValidateAll checks the field values on Settings_ReceiveSettings with the
   179  // rules defined in the proto definition for this message. If any rules are
   180  // violated, the result is a list of violation errors wrapped in
   181  // Settings_ReceiveSettingsMultiError, or nil if none found.
   182  func (m *Settings_ReceiveSettings) ValidateAll() error {
   183  	return m.validate(true)
   184  }
   185  
   186  func (m *Settings_ReceiveSettings) validate(all bool) error {
   187  	if m == nil {
   188  		return nil
   189  	}
   190  
   191  	var errors []error
   192  
   193  	// no validation rules for NumGoroutines
   194  
   195  	// no validation rules for MaxOutstandingMessages
   196  
   197  	if len(errors) > 0 {
   198  		return Settings_ReceiveSettingsMultiError(errors)
   199  	}
   200  
   201  	return nil
   202  }
   203  
   204  // Settings_ReceiveSettingsMultiError is an error wrapping multiple validation
   205  // errors returned by Settings_ReceiveSettings.ValidateAll() if the designated
   206  // constraints aren't met.
   207  type Settings_ReceiveSettingsMultiError []error
   208  
   209  // Error returns a concatenation of all the error messages it wraps.
   210  func (m Settings_ReceiveSettingsMultiError) 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 Settings_ReceiveSettingsMultiError) AllErrors() []error { return m }
   220  
   221  // Settings_ReceiveSettingsValidationError is the validation error returned by
   222  // Settings_ReceiveSettings.Validate if the designated constraints aren't met.
   223  type Settings_ReceiveSettingsValidationError struct {
   224  	field  string
   225  	reason string
   226  	cause  error
   227  	key    bool
   228  }
   229  
   230  // Field function returns field value.
   231  func (e Settings_ReceiveSettingsValidationError) Field() string { return e.field }
   232  
   233  // Reason function returns reason value.
   234  func (e Settings_ReceiveSettingsValidationError) Reason() string { return e.reason }
   235  
   236  // Cause function returns cause value.
   237  func (e Settings_ReceiveSettingsValidationError) Cause() error { return e.cause }
   238  
   239  // Key function returns key value.
   240  func (e Settings_ReceiveSettingsValidationError) Key() bool { return e.key }
   241  
   242  // ErrorName returns error name.
   243  func (e Settings_ReceiveSettingsValidationError) ErrorName() string {
   244  	return "Settings_ReceiveSettingsValidationError"
   245  }
   246  
   247  // Error satisfies the builtin error interface
   248  func (e Settings_ReceiveSettingsValidationError) Error() string {
   249  	cause := ""
   250  	if e.cause != nil {
   251  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   252  	}
   253  
   254  	key := ""
   255  	if e.key {
   256  		key = "key for "
   257  	}
   258  
   259  	return fmt.Sprintf(
   260  		"invalid %sSettings_ReceiveSettings.%s: %s%s",
   261  		key,
   262  		e.field,
   263  		e.reason,
   264  		cause)
   265  }
   266  
   267  var _ error = Settings_ReceiveSettingsValidationError{}
   268  
   269  var _ interface {
   270  	Field() string
   271  	Reason() string
   272  	Key() bool
   273  	Cause() error
   274  	ErrorName() string
   275  } = Settings_ReceiveSettingsValidationError{}
   276  
   277  // Validate checks the field values on Settings_GerritSubscription with the
   278  // rules defined in the proto definition for this message. If any rules are
   279  // violated, the first error encountered is returned, or nil if there are no violations.
   280  func (m *Settings_GerritSubscription) Validate() error {
   281  	return m.validate(false)
   282  }
   283  
   284  // ValidateAll checks the field values on Settings_GerritSubscription with the
   285  // rules defined in the proto definition for this message. If any rules are
   286  // violated, the result is a list of violation errors wrapped in
   287  // Settings_GerritSubscriptionMultiError, or nil if none found.
   288  func (m *Settings_GerritSubscription) ValidateAll() error {
   289  	return m.validate(true)
   290  }
   291  
   292  func (m *Settings_GerritSubscription) validate(all bool) error {
   293  	if m == nil {
   294  		return nil
   295  	}
   296  
   297  	var errors []error
   298  
   299  	if utf8.RuneCountInString(m.GetHost()) < 1 {
   300  		err := Settings_GerritSubscriptionValidationError{
   301  			field:  "Host",
   302  			reason: "value length must be at least 1 runes",
   303  		}
   304  		if !all {
   305  			return err
   306  		}
   307  		errors = append(errors, err)
   308  	}
   309  
   310  	if strings.Contains(m.GetHost(), "/") {
   311  		err := Settings_GerritSubscriptionValidationError{
   312  			field:  "Host",
   313  			reason: "value contains substring \"/\"",
   314  		}
   315  		if !all {
   316  			return err
   317  		}
   318  		errors = append(errors, err)
   319  	}
   320  
   321  	// no validation rules for SubscriptionId
   322  
   323  	if all {
   324  		switch v := interface{}(m.GetReceiveSettings()).(type) {
   325  		case interface{ ValidateAll() error }:
   326  			if err := v.ValidateAll(); err != nil {
   327  				errors = append(errors, Settings_GerritSubscriptionValidationError{
   328  					field:  "ReceiveSettings",
   329  					reason: "embedded message failed validation",
   330  					cause:  err,
   331  				})
   332  			}
   333  		case interface{ Validate() error }:
   334  			if err := v.Validate(); err != nil {
   335  				errors = append(errors, Settings_GerritSubscriptionValidationError{
   336  					field:  "ReceiveSettings",
   337  					reason: "embedded message failed validation",
   338  					cause:  err,
   339  				})
   340  			}
   341  		}
   342  	} else if v, ok := interface{}(m.GetReceiveSettings()).(interface{ Validate() error }); ok {
   343  		if err := v.Validate(); err != nil {
   344  			return Settings_GerritSubscriptionValidationError{
   345  				field:  "ReceiveSettings",
   346  				reason: "embedded message failed validation",
   347  				cause:  err,
   348  			}
   349  		}
   350  	}
   351  
   352  	// no validation rules for MessageFormat
   353  
   354  	if len(errors) > 0 {
   355  		return Settings_GerritSubscriptionMultiError(errors)
   356  	}
   357  
   358  	return nil
   359  }
   360  
   361  // Settings_GerritSubscriptionMultiError is an error wrapping multiple
   362  // validation errors returned by Settings_GerritSubscription.ValidateAll() if
   363  // the designated constraints aren't met.
   364  type Settings_GerritSubscriptionMultiError []error
   365  
   366  // Error returns a concatenation of all the error messages it wraps.
   367  func (m Settings_GerritSubscriptionMultiError) Error() string {
   368  	var msgs []string
   369  	for _, err := range m {
   370  		msgs = append(msgs, err.Error())
   371  	}
   372  	return strings.Join(msgs, "; ")
   373  }
   374  
   375  // AllErrors returns a list of validation violation errors.
   376  func (m Settings_GerritSubscriptionMultiError) AllErrors() []error { return m }
   377  
   378  // Settings_GerritSubscriptionValidationError is the validation error returned
   379  // by Settings_GerritSubscription.Validate if the designated constraints
   380  // aren't met.
   381  type Settings_GerritSubscriptionValidationError struct {
   382  	field  string
   383  	reason string
   384  	cause  error
   385  	key    bool
   386  }
   387  
   388  // Field function returns field value.
   389  func (e Settings_GerritSubscriptionValidationError) Field() string { return e.field }
   390  
   391  // Reason function returns reason value.
   392  func (e Settings_GerritSubscriptionValidationError) Reason() string { return e.reason }
   393  
   394  // Cause function returns cause value.
   395  func (e Settings_GerritSubscriptionValidationError) Cause() error { return e.cause }
   396  
   397  // Key function returns key value.
   398  func (e Settings_GerritSubscriptionValidationError) Key() bool { return e.key }
   399  
   400  // ErrorName returns error name.
   401  func (e Settings_GerritSubscriptionValidationError) ErrorName() string {
   402  	return "Settings_GerritSubscriptionValidationError"
   403  }
   404  
   405  // Error satisfies the builtin error interface
   406  func (e Settings_GerritSubscriptionValidationError) Error() string {
   407  	cause := ""
   408  	if e.cause != nil {
   409  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   410  	}
   411  
   412  	key := ""
   413  	if e.key {
   414  		key = "key for "
   415  	}
   416  
   417  	return fmt.Sprintf(
   418  		"invalid %sSettings_GerritSubscription.%s: %s%s",
   419  		key,
   420  		e.field,
   421  		e.reason,
   422  		cause)
   423  }
   424  
   425  var _ error = Settings_GerritSubscriptionValidationError{}
   426  
   427  var _ interface {
   428  	Field() string
   429  	Reason() string
   430  	Key() bool
   431  	Cause() error
   432  	ErrorName() string
   433  } = Settings_GerritSubscriptionValidationError{}