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

     1  // Code generated by protoc-gen-goten-validate
     2  // File: edgelq/iam/proto/v1/condition.proto
     3  // DO NOT EDIT!!!
     4  
     5  package condition
     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  	attestation_domain "github.com/cloudwan/edgelq-sdk/iam/resources/v1/attestation_domain"
    24  	organization "github.com/cloudwan/edgelq-sdk/iam/resources/v1/organization"
    25  	permission "github.com/cloudwan/edgelq-sdk/iam/resources/v1/permission"
    26  	project "github.com/cloudwan/edgelq-sdk/iam/resources/v1/project"
    27  	meta_service "github.com/cloudwan/goten-sdk/meta-service/resources/v1/service"
    28  	meta "github.com/cloudwan/goten-sdk/types/meta"
    29  	structpb "google.golang.org/protobuf/types/known/structpb"
    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  	_ = &attestation_domain.AttestationDomain{}
    48  	_ = &organization.Organization{}
    49  	_ = &permission.Permission{}
    50  	_ = &project.Project{}
    51  	_ = &structpb.Struct{}
    52  	_ = &meta_service.Service{}
    53  	_ = &meta.Meta{}
    54  )
    55  
    56  func (obj *Condition) 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("Condition", "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("Condition", "displayName", obj.DisplayName, "field must contain at most 256 characters", nil)
    69  		}
    70  	}
    71  	{
    72  		rlen := utf8.RuneCountInString(obj.Description)
    73  		if rlen > 1024 {
    74  			return gotenvalidate.NewValidationError("Condition", "description", obj.Description, "field must contain at most 1024 characters", nil)
    75  		}
    76  	}
    77  	for idx, elem := range obj.ParameterDeclarations {
    78  		if subobj, ok := interface{}(elem).(gotenvalidate.Validator); ok {
    79  			if err := subobj.GotenValidate(); err != nil {
    80  				return gotenvalidate.NewValidationError("Condition", "parameterDeclarations", obj.ParameterDeclarations[idx], "nested object validation failed", err)
    81  			}
    82  		}
    83  	}
    84  	switch opt := obj.Condition.(type) {
    85  	case *Condition_IpCondition_:
    86  		if subobj, ok := interface{}(opt.IpCondition).(gotenvalidate.Validator); ok {
    87  			if err := subobj.GotenValidate(); err != nil {
    88  				return gotenvalidate.NewValidationError("Condition", "ipCondition", opt.IpCondition, "nested object validation failed", err)
    89  			}
    90  		}
    91  	case *Condition_AttestationCondition_:
    92  		if subobj, ok := interface{}(opt.AttestationCondition).(gotenvalidate.Validator); ok {
    93  			if err := subobj.GotenValidate(); err != nil {
    94  				return gotenvalidate.NewValidationError("Condition", "attestationCondition", opt.AttestationCondition, "nested object validation failed", err)
    95  			}
    96  		}
    97  	default:
    98  		_ = opt
    99  	}
   100  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   101  		return cvobj.GotenCustomValidate()
   102  	}
   103  	return nil
   104  }
   105  func (obj *Condition_ParameterDeclaration) GotenValidate() error {
   106  	if obj == nil {
   107  		return nil
   108  	}
   109  	if obj.Key == "" {
   110  		return gotenvalidate.NewValidationError("ParameterDeclaration", "key", obj.Key, "field is required", nil)
   111  	}
   112  	if _, ok := Condition_ParameterType_name[int32(obj.Type)]; !ok {
   113  		return gotenvalidate.NewValidationError("ParameterDeclaration", "type", obj.Type, "field must be a defined enum value", nil)
   114  	}
   115  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   116  		return cvobj.GotenCustomValidate()
   117  	}
   118  	return nil
   119  }
   120  func (obj *Condition_IpCondition) GotenValidate() error {
   121  	if obj == nil {
   122  		return nil
   123  	}
   124  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   125  		return cvobj.GotenCustomValidate()
   126  	}
   127  	return nil
   128  }
   129  func (obj *Condition_AttestationCondition) GotenValidate() error {
   130  	if obj == nil {
   131  		return nil
   132  	}
   133  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   134  		return cvobj.GotenCustomValidate()
   135  	}
   136  	return nil
   137  }
   138  func (obj *ExecutableCondition) GotenValidate() error {
   139  	if obj == nil {
   140  		return nil
   141  	}
   142  	if cvobj, ok := interface{}(obj).(gotenvalidate.CustomValidator); ok {
   143  		return cvobj.GotenCustomValidate()
   144  	}
   145  	return nil
   146  }