github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/policy/policy.pb.validate.go (about)

     1  // Code generated by protoc-gen-goten-validate
     2  // File: edgelq/alerting/proto/v1/policy.proto
     3  // DO NOT EDIT!!!
     4  
     5  package policy
     6  
     7  import (
     8  	"bytes"
     9  	"errors"
    10  	"fmt"
    11  	"net"
    12  	"net/url"
    13  	"regexp"
    14  	"strings"
    15  	"time"
    16  	"unicode/utf8"
    17  
    18  	gotenvalidate "github.com/cloudwan/goten-sdk/runtime/validate"
    19  )
    20  
    21  // proto imports
    22  import (
    23  	rcommon "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/common"
    24  	document "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/document"
    25  	notification_channel "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/notification_channel"
    26  	policy_template "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/policy_template"
    27  	iam_project "github.com/cloudwan/edgelq-sdk/iam/resources/v1/project"
    28  	meta "github.com/cloudwan/goten-sdk/types/meta"
    29  	fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
    30  )
    31  
    32  var (
    33  	_ = bytes.Equal
    34  	_ = errors.New
    35  	_ = fmt.Errorf
    36  	_ = net.ParseIP
    37  	_ = regexp.Match
    38  	_ = strings.Split
    39  	_ = time.Now
    40  	_ = utf8.RuneCountInString
    41  	_ = url.Parse
    42  	_ = gotenvalidate.NewValidationError
    43  )
    44  
    45  // make sure we're using proto imports
    46  var (
    47  	_ = &document.Document{}
    48  	_ = &notification_channel.NotificationChannel{}
    49  	_ = &policy_template.PolicyTemplate{}
    50  	_ = &rcommon.LogCndSpec{}
    51  	_ = &iam_project.Project{}
    52  	_ = &fieldmaskpb.FieldMask{}
    53  	_ = &meta.Meta{}
    54  )
    55  
    56  func (obj *Policy) GotenValidate() error {
    57  	if obj == nil {
    58  		return nil
    59  	}
    60  	if subobj, ok := interface{}(obj.Metadata).(gotenvalidate.Validator); ok {
    61  		if err := subobj.GotenValidate(); err != nil {
    62  			return gotenvalidate.NewValidationError("Policy", "metadata", obj.Metadata, "nested object validation failed", err)
    63  		}
    64  	}
    65  	{
    66  		rlen := utf8.RuneCountInString(obj.DisplayName)
    67  		if rlen > 256 {
    68  			return gotenvalidate.NewValidationError("Policy", "displayName", obj.DisplayName, "field must contain at most 256 characters", nil)
    69  		}
    70  	}
    71  	{
    72  		rlen := utf8.RuneCountInString(obj.Description)
    73  		if rlen > 512 {
    74  			return gotenvalidate.NewValidationError("Policy", "description", obj.Description, "field must contain at most 512 characters", nil)
    75  		}
    76  	}
    77  	if obj.Spec == nil {
    78  		return gotenvalidate.NewValidationError("Policy", "spec", obj.Spec, "field is required", nil)
    79  	}
    80  	if subobj, ok := interface{}(obj.Spec).(gotenvalidate.Validator); ok {
    81  		if err := subobj.GotenValidate(); err != nil {
    82  			return gotenvalidate.NewValidationError("Policy", "spec", obj.Spec, "nested object validation failed", err)
    83  		}
    84  	}
    85  	if subobj, ok := interface{}(obj.TemplateSource).(gotenvalidate.Validator); ok {
    86  		if err := subobj.GotenValidate(); err != nil {
    87  			return gotenvalidate.NewValidationError("Policy", "templateSource", obj.TemplateSource, "nested object validation failed", err)
    88  		}
    89  	}
    90  	if len(obj.NotificationChannels) > 8 {
    91  		return gotenvalidate.NewValidationError("Policy", "notificationChannels", obj.NotificationChannels, "field must have at most 8 items", nil)
    92  	}
    93  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
    94  		return cvobj.GotenCustomValidate()
    95  	}
    96  	return nil
    97  }
    98  func (obj *Policy_TemplateSource) GotenValidate() error {
    99  	if obj == nil {
   100  		return nil
   101  	}
   102  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   103  		return cvobj.GotenCustomValidate()
   104  	}
   105  	return nil
   106  }