go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/cv/internal/run/eventpb/submission.pb.validate.go (about)

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