mirror of
https://dev.azure.com/schwarzit/schwarzit.stackit-public/_git/audit-go
synced 2026-02-07 16:47:24 +00:00
Update buf configuration
This commit is contained in:
parent
07d8183f88
commit
0a8516f4a3
11 changed files with 177 additions and 16510 deletions
129
audit/schema/routable_event_test.go
Normal file
129
audit/schema/routable_event_test.go
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"dev.azure.com/schwarzit/schwarzit.stackit-core-platform/audit-go.git/audit/api"
|
||||
auditV1 "dev.azure.com/schwarzit/schwarzit.stackit-core-platform/audit-go.git/gen/go/audit/v1"
|
||||
"github.com/bufbuild/protovalidate-go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_RoutableAuditEvent(t *testing.T) {
|
||||
|
||||
validator, err := protovalidate.New()
|
||||
assert.NoError(t, err)
|
||||
|
||||
newEvent := func() auditV1.RoutableAuditEvent {
|
||||
return auditV1.RoutableAuditEvent{
|
||||
OperationName: "stackit.resource-manager.v1.organizations.create",
|
||||
Visibility: auditV1.Visibility_VISIBILITY_PUBLIC,
|
||||
ObjectIdentifier: &auditV1.ObjectIdentifier{
|
||||
Identifier: "14f7aa86-77ba-4d77-a091-a2cf3395a221",
|
||||
Type: string(api.SingularTypeProject),
|
||||
},
|
||||
Data: &auditV1.RoutableAuditEvent_UnencryptedData{UnencryptedData: &auditV1.UnencryptedData{
|
||||
Data: []byte("data"),
|
||||
ProtobufType: "audit.v1.AuditLogEntry",
|
||||
}}}
|
||||
}
|
||||
|
||||
t.Run("valid event", func(t *testing.T) {
|
||||
event := newEvent()
|
||||
err := validator.Validate(&event)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("empty operation name", func(t *testing.T) {
|
||||
event := newEvent()
|
||||
event.OperationName = ""
|
||||
|
||||
err := validator.Validate(&event)
|
||||
assert.EqualError(t, err, "validation error:\n - operation_name: value is required [required]")
|
||||
})
|
||||
|
||||
t.Run("invalid operation name", func(t *testing.T) {
|
||||
event := newEvent()
|
||||
event.OperationName = "stackit.resource-manager.v1.INVALID.organizations.create"
|
||||
|
||||
err := validator.Validate(&event)
|
||||
assert.EqualError(t, err, "validation error:\n - operation_name: value does not match regex pattern `^stackit\\.[a-z0-9-]+\\.(?:v[1-9][0-9]*\\.)?(?:[a-z0-9-.]+\\.)?[a-z0-9-]+$` [string.pattern]")
|
||||
})
|
||||
|
||||
t.Run("visibility invalid", func(t *testing.T) {
|
||||
event := newEvent()
|
||||
event.Visibility = -1
|
||||
|
||||
err := validator.Validate(&event)
|
||||
assert.EqualError(t, err, "validation error:\n - visibility: value must be one of the defined enum values [enum.defined_only]")
|
||||
})
|
||||
|
||||
t.Run("visibility unspecified", func(t *testing.T) {
|
||||
event := newEvent()
|
||||
event.Visibility = auditV1.Visibility_VISIBILITY_UNSPECIFIED
|
||||
|
||||
err := validator.Validate(&event)
|
||||
assert.EqualError(t, err, "validation error:\n - visibility: value is required [required]")
|
||||
})
|
||||
|
||||
t.Run("object identifier nil", func(t *testing.T) {
|
||||
event := newEvent()
|
||||
event.ObjectIdentifier = nil
|
||||
|
||||
err := validator.Validate(&event)
|
||||
assert.EqualError(t, err, "validation error:\n - object_identifier: value is required [required]")
|
||||
})
|
||||
|
||||
t.Run("object identifier id empty", func(t *testing.T) {
|
||||
event := newEvent()
|
||||
event.ObjectIdentifier.Identifier = ""
|
||||
|
||||
err := validator.Validate(&event)
|
||||
assert.EqualError(t, err, "validation error:\n - object_identifier.identifier: value is required [required]")
|
||||
})
|
||||
|
||||
t.Run("object identifier id not uuid", func(t *testing.T) {
|
||||
event := newEvent()
|
||||
event.ObjectIdentifier.Identifier = "invalid"
|
||||
|
||||
err := validator.Validate(&event)
|
||||
assert.EqualError(t, err, "validation error:\n - object_identifier.identifier: value must be a valid UUID [string.uuid]")
|
||||
})
|
||||
|
||||
t.Run("object identifier type empty", func(t *testing.T) {
|
||||
event := newEvent()
|
||||
event.ObjectIdentifier.Type = ""
|
||||
|
||||
err := validator.Validate(&event)
|
||||
assert.EqualError(t, err, "validation error:\n - object_identifier.type: value is required [required]")
|
||||
})
|
||||
|
||||
t.Run("data nil", func(t *testing.T) {
|
||||
event := newEvent()
|
||||
event.Data = nil
|
||||
|
||||
err := validator.Validate(&event)
|
||||
assert.EqualError(t, err, "validation error:\n - data: exactly one field is required in oneof [required]")
|
||||
})
|
||||
|
||||
t.Run("data empty", func(t *testing.T) {
|
||||
event := newEvent()
|
||||
event.Data = &auditV1.RoutableAuditEvent_UnencryptedData{UnencryptedData: &auditV1.UnencryptedData{
|
||||
Data: []byte{},
|
||||
ProtobufType: "audit.v1.AuditLogEntry",
|
||||
}}
|
||||
|
||||
err := validator.Validate(&event)
|
||||
assert.EqualError(t, err, "validation error:\n - unencrypted_data.data: value is required [required]")
|
||||
})
|
||||
|
||||
t.Run("data protobuf type empty", func(t *testing.T) {
|
||||
event := newEvent()
|
||||
event.Data = &auditV1.RoutableAuditEvent_UnencryptedData{UnencryptedData: &auditV1.UnencryptedData{
|
||||
Data: []byte("data"),
|
||||
ProtobufType: "",
|
||||
}}
|
||||
|
||||
err := validator.Validate(&event)
|
||||
assert.EqualError(t, err, "validation error:\n - unencrypted_data.protobuf_type: value is required [required]")
|
||||
})
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc (unknown)
|
||||
// source: audit/v1/audit_event.proto
|
||||
|
||||
|
|
@ -1867,16 +1867,11 @@ var file_audit_v1_audit_event_proto_rawDesc = []byte{
|
|||
0xbc, 0x05, 0x12, 0x17, 0x0a, 0x12, 0x4c, 0x4f, 0x47, 0x5f, 0x53, 0x45, 0x56, 0x45, 0x52, 0x49,
|
||||
0x54, 0x59, 0x5f, 0x41, 0x4c, 0x45, 0x52, 0x54, 0x10, 0xa0, 0x06, 0x12, 0x1b, 0x0a, 0x16, 0x4c,
|
||||
0x4f, 0x47, 0x5f, 0x53, 0x45, 0x56, 0x45, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x45, 0x4d, 0x45, 0x52,
|
||||
0x47, 0x45, 0x4e, 0x43, 0x59, 0x10, 0x84, 0x07, 0x42, 0x81, 0x01, 0x0a, 0x1c, 0x63, 0x6f, 0x6d,
|
||||
0x2e, 0x73, 0x63, 0x68, 0x77, 0x61, 0x72, 0x7a, 0x2e, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x69, 0x74,
|
||||
0x2e, 0x61, 0x75, 0x64, 0x69, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x0f, 0x41, 0x75, 0x64, 0x69, 0x74,
|
||||
0x45, 0x76, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x0f, 0x2e, 0x2f,
|
||||
0x61, 0x75, 0x64, 0x69, 0x74, 0x3b, 0x61, 0x75, 0x64, 0x69, 0x74, 0x56, 0x31, 0xa2, 0x02, 0x03,
|
||||
0x41, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x41, 0x75, 0x64, 0x69, 0x74, 0x2e, 0x56, 0x31, 0xca, 0x02,
|
||||
0x08, 0x41, 0x75, 0x64, 0x69, 0x74, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x14, 0x41, 0x75, 0x64, 0x69,
|
||||
0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
|
||||
0xea, 0x02, 0x09, 0x41, 0x75, 0x64, 0x69, 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
0x47, 0x45, 0x4e, 0x43, 0x59, 0x10, 0x84, 0x07, 0x42, 0x31, 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 0x2e,
|
||||
0x73, 0x63, 0x68, 0x77, 0x61, 0x72, 0x7a, 0x2e, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x69, 0x74, 0x2e,
|
||||
0x61, 0x75, 0x64, 0x69, 0x74, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a, 0x0f, 0x2e, 0x2f, 0x61, 0x75,
|
||||
0x64, 0x69, 0x74, 0x3b, 0x61, 0x75, 0x64, 0x69, 0x74, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
@ -1893,7 +1888,7 @@ func file_audit_v1_audit_event_proto_rawDescGZIP() []byte {
|
|||
|
||||
var file_audit_v1_audit_event_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_audit_v1_audit_event_proto_msgTypes = make([]protoimpl.MessageInfo, 16)
|
||||
var file_audit_v1_audit_event_proto_goTypes = []interface{}{
|
||||
var file_audit_v1_audit_event_proto_goTypes = []any{
|
||||
(LogSeverity)(0), // 0: audit.v1.LogSeverity
|
||||
(AttributeContext_HttpMethod)(0), // 1: audit.v1.AttributeContext.HttpMethod
|
||||
(*AuditLogEntry)(nil), // 2: audit.v1.AuditLogEntry
|
||||
|
|
@ -1960,7 +1955,7 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_audit_v1_audit_event_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_audit_event_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AuditLogEntry); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1972,7 +1967,7 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_audit_event_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AuditLog); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1984,7 +1979,7 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_audit_event_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AuthenticationInfo); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1996,7 +1991,7 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_audit_event_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AuthorizationInfo); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2008,7 +2003,7 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_audit_event_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AttributeContext); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2020,7 +2015,7 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_audit_event_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RequestMetadata); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2032,7 +2027,7 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_audit_event_proto_msgTypes[6].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ResponseMetadata); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2044,7 +2039,7 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_audit_event_proto_msgTypes[7].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ServiceAccountDelegationInfo); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2056,7 +2051,7 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_audit_event_proto_msgTypes[9].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AttributeContext_Auth); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2068,7 +2063,7 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_audit_event_proto_msgTypes[10].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AttributeContext_Request); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2080,7 +2075,7 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_audit_event_proto_msgTypes[11].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AttributeContext_Response); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2092,7 +2087,7 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_audit_event_proto_msgTypes[14].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ServiceAccountDelegationInfo_SystemPrincipal); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2104,7 +2099,7 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_audit_event_proto_msgTypes[15].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ServiceAccountDelegationInfo_IdpPrincipal); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2117,19 +2112,19 @@ func file_audit_v1_audit_event_proto_init() {
|
|||
}
|
||||
}
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[0].OneofWrappers = []interface{}{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[1].OneofWrappers = []interface{}{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[2].OneofWrappers = []interface{}{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[3].OneofWrappers = []interface{}{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[6].OneofWrappers = []interface{}{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[7].OneofWrappers = []interface{}{
|
||||
file_audit_v1_audit_event_proto_msgTypes[0].OneofWrappers = []any{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[1].OneofWrappers = []any{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[2].OneofWrappers = []any{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[3].OneofWrappers = []any{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[6].OneofWrappers = []any{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[7].OneofWrappers = []any{
|
||||
(*ServiceAccountDelegationInfo_SystemPrincipal_)(nil),
|
||||
(*ServiceAccountDelegationInfo_IdpPrincipal_)(nil),
|
||||
}
|
||||
file_audit_v1_audit_event_proto_msgTypes[10].OneofWrappers = []interface{}{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[11].OneofWrappers = []interface{}{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[14].OneofWrappers = []interface{}{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[15].OneofWrappers = []interface{}{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[10].OneofWrappers = []any{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[11].OneofWrappers = []any{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[14].OneofWrappers = []any{}
|
||||
file_audit_v1_audit_event_proto_msgTypes[15].OneofWrappers = []any{}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc-gen-go v1.34.2
|
||||
// protoc (unknown)
|
||||
// source: audit/v1/routable_event.proto
|
||||
|
||||
|
|
@ -481,16 +481,11 @@ var file_audit_v1_routable_event_proto_rawDesc = []byte{
|
|||
0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x56, 0x49,
|
||||
0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x10,
|
||||
0x01, 0x12, 0x16, 0x0a, 0x12, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f,
|
||||
0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x10, 0x02, 0x42, 0x84, 0x01, 0x0a, 0x1c, 0x63, 0x6f,
|
||||
0x6d, 0x2e, 0x73, 0x63, 0x68, 0x77, 0x61, 0x72, 0x7a, 0x2e, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x69,
|
||||
0x74, 0x2e, 0x61, 0x75, 0x64, 0x69, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x12, 0x52, 0x6f, 0x75, 0x74,
|
||||
0x61, 0x62, 0x6c, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01,
|
||||
0x5a, 0x0f, 0x2e, 0x2f, 0x61, 0x75, 0x64, 0x69, 0x74, 0x3b, 0x61, 0x75, 0x64, 0x69, 0x74, 0x56,
|
||||
0x31, 0xa2, 0x02, 0x03, 0x41, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x41, 0x75, 0x64, 0x69, 0x74, 0x2e,
|
||||
0x56, 0x31, 0xca, 0x02, 0x08, 0x41, 0x75, 0x64, 0x69, 0x74, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x14,
|
||||
0x41, 0x75, 0x64, 0x69, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61,
|
||||
0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x41, 0x75, 0x64, 0x69, 0x74, 0x3a, 0x3a, 0x56, 0x31,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x10, 0x02, 0x42, 0x31, 0x0a, 0x1c, 0x63, 0x6f, 0x6d,
|
||||
0x2e, 0x73, 0x63, 0x68, 0x77, 0x61, 0x72, 0x7a, 0x2e, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x69, 0x74,
|
||||
0x2e, 0x61, 0x75, 0x64, 0x69, 0x74, 0x2e, 0x76, 0x31, 0x50, 0x01, 0x5a, 0x0f, 0x2e, 0x2f, 0x61,
|
||||
0x75, 0x64, 0x69, 0x74, 0x3b, 0x61, 0x75, 0x64, 0x69, 0x74, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
@ -507,7 +502,7 @@ func file_audit_v1_routable_event_proto_rawDescGZIP() []byte {
|
|||
|
||||
var file_audit_v1_routable_event_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_audit_v1_routable_event_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_audit_v1_routable_event_proto_goTypes = []interface{}{
|
||||
var file_audit_v1_routable_event_proto_goTypes = []any{
|
||||
(Visibility)(0), // 0: audit.v1.Visibility
|
||||
(*ObjectIdentifier)(nil), // 1: audit.v1.ObjectIdentifier
|
||||
(*EncryptedData)(nil), // 2: audit.v1.EncryptedData
|
||||
|
|
@ -532,7 +527,7 @@ func file_audit_v1_routable_event_proto_init() {
|
|||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_audit_v1_routable_event_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_routable_event_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ObjectIdentifier); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -544,7 +539,7 @@ func file_audit_v1_routable_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_routable_event_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_routable_event_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*EncryptedData); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -556,7 +551,7 @@ func file_audit_v1_routable_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_routable_event_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_routable_event_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*UnencryptedData); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -568,7 +563,7 @@ func file_audit_v1_routable_event_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_audit_v1_routable_event_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_audit_v1_routable_event_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RoutableAuditEvent); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -581,7 +576,7 @@ func file_audit_v1_routable_event_proto_init() {
|
|||
}
|
||||
}
|
||||
}
|
||||
file_audit_v1_routable_event_proto_msgTypes[3].OneofWrappers = []interface{}{
|
||||
file_audit_v1_routable_event_proto_msgTypes[3].OneofWrappers = []any{
|
||||
(*RoutableAuditEvent_UnencryptedData)(nil),
|
||||
(*RoutableAuditEvent_EncryptedData)(nil),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,397 +0,0 @@
|
|||
// Copyright 2023 Buf Technologies, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc (unknown)
|
||||
// source: buf/validate/expression.proto
|
||||
|
||||
package validate
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// `Constraint` represents a validation rule written in the Common Expression
|
||||
// Language (CEL) syntax. Each Constraint includes a unique identifier, an
|
||||
// optional error message, and the CEL expression to evaluate. For more
|
||||
// information on CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md).
|
||||
//
|
||||
// ```proto
|
||||
//
|
||||
// message Foo {
|
||||
// option (buf.validate.message).cel = {
|
||||
// id: "foo.bar"
|
||||
// message: "bar must be greater than 0"
|
||||
// expression: "this.bar > 0"
|
||||
// };
|
||||
// int32 bar = 1;
|
||||
// }
|
||||
//
|
||||
// ```
|
||||
type Constraint struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// `id` is a string that serves as a machine-readable name for this Constraint.
|
||||
// It should be unique within its scope, which could be either a message or a field.
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
// `message` is an optional field that provides a human-readable error message
|
||||
// for this Constraint when the CEL expression evaluates to false. If a
|
||||
// non-empty message is provided, any strings resulting from the CEL
|
||||
// expression evaluation are ignored.
|
||||
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
|
||||
// `expression` is the actual CEL expression that will be evaluated for
|
||||
// validation. This string must resolve to either a boolean or a string
|
||||
// value. If the expression evaluates to false or a non-empty string, the
|
||||
// validation is considered failed, and the message is rejected.
|
||||
Expression string `protobuf:"bytes,3,opt,name=expression,proto3" json:"expression,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Constraint) Reset() {
|
||||
*x = Constraint{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_buf_validate_expression_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Constraint) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Constraint) ProtoMessage() {}
|
||||
|
||||
func (x *Constraint) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_buf_validate_expression_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Constraint.ProtoReflect.Descriptor instead.
|
||||
func (*Constraint) Descriptor() ([]byte, []int) {
|
||||
return file_buf_validate_expression_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Constraint) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Constraint) GetMessage() string {
|
||||
if x != nil {
|
||||
return x.Message
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Constraint) GetExpression() string {
|
||||
if x != nil {
|
||||
return x.Expression
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// `Violations` is a collection of `Violation` messages. This message type is returned by
|
||||
// protovalidate when a proto message fails to meet the requirements set by the `Constraint` validation rules.
|
||||
// Each individual violation is represented by a `Violation` message.
|
||||
type Violations struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// `violations` is a repeated field that contains all the `Violation` messages corresponding to the violations detected.
|
||||
Violations []*Violation `protobuf:"bytes,1,rep,name=violations,proto3" json:"violations,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Violations) Reset() {
|
||||
*x = Violations{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_buf_validate_expression_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Violations) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Violations) ProtoMessage() {}
|
||||
|
||||
func (x *Violations) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_buf_validate_expression_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Violations.ProtoReflect.Descriptor instead.
|
||||
func (*Violations) Descriptor() ([]byte, []int) {
|
||||
return file_buf_validate_expression_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *Violations) GetViolations() []*Violation {
|
||||
if x != nil {
|
||||
return x.Violations
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// `Violation` represents a single instance where a validation rule, expressed
|
||||
// as a `Constraint`, was not met. It provides information about the field that
|
||||
// caused the violation, the specific constraint that wasn't fulfilled, and a
|
||||
// human-readable error message.
|
||||
//
|
||||
// ```json
|
||||
//
|
||||
// {
|
||||
// "fieldPath": "bar",
|
||||
// "constraintId": "foo.bar",
|
||||
// "message": "bar must be greater than 0"
|
||||
// }
|
||||
//
|
||||
// ```
|
||||
type Violation struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// `field_path` is a machine-readable identifier that points to the specific field that failed the validation.
|
||||
// This could be a nested field, in which case the path will include all the parent fields leading to the actual field that caused the violation.
|
||||
FieldPath string `protobuf:"bytes,1,opt,name=field_path,json=fieldPath,proto3" json:"field_path,omitempty"`
|
||||
// `constraint_id` is the unique identifier of the `Constraint` that was not fulfilled.
|
||||
// This is the same `id` that was specified in the `Constraint` message, allowing easy tracing of which rule was violated.
|
||||
ConstraintId string `protobuf:"bytes,2,opt,name=constraint_id,json=constraintId,proto3" json:"constraint_id,omitempty"`
|
||||
// `message` is a human-readable error message that describes the nature of the violation.
|
||||
// This can be the default error message from the violated `Constraint`, or it can be a custom message that gives more context about the violation.
|
||||
Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
|
||||
// `for_key` indicates whether the violation was caused by a map key, rather than a value.
|
||||
ForKey bool `protobuf:"varint,4,opt,name=for_key,json=forKey,proto3" json:"for_key,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Violation) Reset() {
|
||||
*x = Violation{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_buf_validate_expression_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Violation) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Violation) ProtoMessage() {}
|
||||
|
||||
func (x *Violation) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_buf_validate_expression_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Violation.ProtoReflect.Descriptor instead.
|
||||
func (*Violation) Descriptor() ([]byte, []int) {
|
||||
return file_buf_validate_expression_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Violation) GetFieldPath() string {
|
||||
if x != nil {
|
||||
return x.FieldPath
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Violation) GetConstraintId() string {
|
||||
if x != nil {
|
||||
return x.ConstraintId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Violation) GetMessage() string {
|
||||
if x != nil {
|
||||
return x.Message
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Violation) GetForKey() bool {
|
||||
if x != nil {
|
||||
return x.ForKey
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var File_buf_validate_expression_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_buf_validate_expression_proto_rawDesc = []byte{
|
||||
0x0a, 0x1d, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x65,
|
||||
0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||
0x0c, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x22, 0x56, 0x0a,
|
||||
0x0a, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69,
|
||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d,
|
||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65,
|
||||
0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73,
|
||||
0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x72, 0x65,
|
||||
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x45, 0x0a, 0x0a, 0x56, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x12, 0x37, 0x0a, 0x0a, 0x76, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61,
|
||||
0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x56, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x52, 0x0a, 0x76, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x82, 0x01, 0x0a,
|
||||
0x09, 0x56, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x69,
|
||||
0x65, 0x6c, 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
|
||||
0x66, 0x69, 0x65, 0x6c, 0x64, 0x50, 0x61, 0x74, 0x68, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x6e,
|
||||
0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x18,
|
||||
0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x6f, 0x72, 0x5f,
|
||||
0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x4b, 0x65,
|
||||
0x79, 0x42, 0xbf, 0x01, 0x0a, 0x12, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2e, 0x62, 0x75, 0x66, 0x2e,
|
||||
0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x42, 0x0f, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x62, 0x75, 0x66,
|
||||
0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75,
|
||||
0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69,
|
||||
0x64, 0x61, 0x74, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x62, 0x75, 0x66,
|
||||
0x66, 0x65, 0x72, 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69,
|
||||
0x64, 0x61, 0x74, 0x65, 0xa2, 0x02, 0x03, 0x42, 0x56, 0x58, 0xaa, 0x02, 0x0c, 0x42, 0x75, 0x66,
|
||||
0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0xca, 0x02, 0x0c, 0x42, 0x75, 0x66, 0x5c,
|
||||
0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0xe2, 0x02, 0x18, 0x42, 0x75, 0x66, 0x5c, 0x56,
|
||||
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64,
|
||||
0x61, 0x74, 0x61, 0xea, 0x02, 0x0d, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x56, 0x61, 0x6c, 0x69, 0x64,
|
||||
0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_buf_validate_expression_proto_rawDescOnce sync.Once
|
||||
file_buf_validate_expression_proto_rawDescData = file_buf_validate_expression_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_buf_validate_expression_proto_rawDescGZIP() []byte {
|
||||
file_buf_validate_expression_proto_rawDescOnce.Do(func() {
|
||||
file_buf_validate_expression_proto_rawDescData = protoimpl.X.CompressGZIP(file_buf_validate_expression_proto_rawDescData)
|
||||
})
|
||||
return file_buf_validate_expression_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_buf_validate_expression_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_buf_validate_expression_proto_goTypes = []interface{}{
|
||||
(*Constraint)(nil), // 0: buf.validate.Constraint
|
||||
(*Violations)(nil), // 1: buf.validate.Violations
|
||||
(*Violation)(nil), // 2: buf.validate.Violation
|
||||
}
|
||||
var file_buf_validate_expression_proto_depIdxs = []int32{
|
||||
2, // 0: buf.validate.Violations.violations:type_name -> buf.validate.Violation
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_buf_validate_expression_proto_init() }
|
||||
func file_buf_validate_expression_proto_init() {
|
||||
if File_buf_validate_expression_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_buf_validate_expression_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Constraint); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_buf_validate_expression_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Violations); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_buf_validate_expression_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Violation); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_buf_validate_expression_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_buf_validate_expression_proto_goTypes,
|
||||
DependencyIndexes: file_buf_validate_expression_proto_depIdxs,
|
||||
MessageInfos: file_buf_validate_expression_proto_msgTypes,
|
||||
}.Build()
|
||||
File_buf_validate_expression_proto = out.File
|
||||
file_buf_validate_expression_proto_rawDesc = nil
|
||||
file_buf_validate_expression_proto_goTypes = nil
|
||||
file_buf_validate_expression_proto_depIdxs = nil
|
||||
}
|
||||
|
|
@ -1,381 +0,0 @@
|
|||
// Code generated by protoc-gen-validate. DO NOT EDIT.
|
||||
// source: buf/validate/expression.proto
|
||||
|
||||
package validate
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/mail"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"google.golang.org/protobuf/types/known/anypb"
|
||||
)
|
||||
|
||||
// ensure the imports are used
|
||||
var (
|
||||
_ = bytes.MinRead
|
||||
_ = errors.New("")
|
||||
_ = fmt.Print
|
||||
_ = utf8.UTFMax
|
||||
_ = (*regexp.Regexp)(nil)
|
||||
_ = (*strings.Reader)(nil)
|
||||
_ = net.IPv4len
|
||||
_ = time.Duration(0)
|
||||
_ = (*url.URL)(nil)
|
||||
_ = (*mail.Address)(nil)
|
||||
_ = anypb.Any{}
|
||||
_ = sort.Sort
|
||||
)
|
||||
|
||||
// Validate checks the field values on Constraint with the rules defined in the
|
||||
// proto definition for this message. If any rules are violated, the first
|
||||
// error encountered is returned, or nil if there are no violations.
|
||||
func (m *Constraint) Validate() error {
|
||||
return m.validate(false)
|
||||
}
|
||||
|
||||
// ValidateAll checks the field values on Constraint with the rules defined in
|
||||
// the proto definition for this message. If any rules are violated, the
|
||||
// result is a list of violation errors wrapped in ConstraintMultiError, or
|
||||
// nil if none found.
|
||||
func (m *Constraint) ValidateAll() error {
|
||||
return m.validate(true)
|
||||
}
|
||||
|
||||
func (m *Constraint) validate(all bool) error {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var errors []error
|
||||
|
||||
// no validation rules for Id
|
||||
|
||||
// no validation rules for Message
|
||||
|
||||
// no validation rules for Expression
|
||||
|
||||
if len(errors) > 0 {
|
||||
return ConstraintMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ConstraintMultiError is an error wrapping multiple validation errors
|
||||
// returned by Constraint.ValidateAll() if the designated constraints aren't met.
|
||||
type ConstraintMultiError []error
|
||||
|
||||
// Error returns a concatenation of all the error messages it wraps.
|
||||
func (m ConstraintMultiError) Error() string {
|
||||
var msgs []string
|
||||
for _, err := range m {
|
||||
msgs = append(msgs, err.Error())
|
||||
}
|
||||
return strings.Join(msgs, "; ")
|
||||
}
|
||||
|
||||
// AllErrors returns a list of validation violation errors.
|
||||
func (m ConstraintMultiError) AllErrors() []error { return m }
|
||||
|
||||
// ConstraintValidationError is the validation error returned by
|
||||
// Constraint.Validate if the designated constraints aren't met.
|
||||
type ConstraintValidationError struct {
|
||||
field string
|
||||
reason string
|
||||
cause error
|
||||
key bool
|
||||
}
|
||||
|
||||
// Field function returns field value.
|
||||
func (e ConstraintValidationError) Field() string { return e.field }
|
||||
|
||||
// Reason function returns reason value.
|
||||
func (e ConstraintValidationError) Reason() string { return e.reason }
|
||||
|
||||
// Cause function returns cause value.
|
||||
func (e ConstraintValidationError) Cause() error { return e.cause }
|
||||
|
||||
// Key function returns key value.
|
||||
func (e ConstraintValidationError) Key() bool { return e.key }
|
||||
|
||||
// ErrorName returns error name.
|
||||
func (e ConstraintValidationError) ErrorName() string { return "ConstraintValidationError" }
|
||||
|
||||
// Error satisfies the builtin error interface
|
||||
func (e ConstraintValidationError) Error() string {
|
||||
cause := ""
|
||||
if e.cause != nil {
|
||||
cause = fmt.Sprintf(" | caused by: %v", e.cause)
|
||||
}
|
||||
|
||||
key := ""
|
||||
if e.key {
|
||||
key = "key for "
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"invalid %sConstraint.%s: %s%s",
|
||||
key,
|
||||
e.field,
|
||||
e.reason,
|
||||
cause)
|
||||
}
|
||||
|
||||
var _ error = ConstraintValidationError{}
|
||||
|
||||
var _ interface {
|
||||
Field() string
|
||||
Reason() string
|
||||
Key() bool
|
||||
Cause() error
|
||||
ErrorName() string
|
||||
} = ConstraintValidationError{}
|
||||
|
||||
// Validate checks the field values on Violations with the rules defined in the
|
||||
// proto definition for this message. If any rules are violated, the first
|
||||
// error encountered is returned, or nil if there are no violations.
|
||||
func (m *Violations) Validate() error {
|
||||
return m.validate(false)
|
||||
}
|
||||
|
||||
// ValidateAll checks the field values on Violations with the rules defined in
|
||||
// the proto definition for this message. If any rules are violated, the
|
||||
// result is a list of violation errors wrapped in ViolationsMultiError, or
|
||||
// nil if none found.
|
||||
func (m *Violations) ValidateAll() error {
|
||||
return m.validate(true)
|
||||
}
|
||||
|
||||
func (m *Violations) validate(all bool) error {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var errors []error
|
||||
|
||||
for idx, item := range m.GetViolations() {
|
||||
_, _ = idx, item
|
||||
|
||||
if all {
|
||||
switch v := interface{}(item).(type) {
|
||||
case interface{ ValidateAll() error }:
|
||||
if err := v.ValidateAll(); err != nil {
|
||||
errors = append(errors, ViolationsValidationError{
|
||||
field: fmt.Sprintf("Violations[%v]", idx),
|
||||
reason: "embedded message failed validation",
|
||||
cause: err,
|
||||
})
|
||||
}
|
||||
case interface{ Validate() error }:
|
||||
if err := v.Validate(); err != nil {
|
||||
errors = append(errors, ViolationsValidationError{
|
||||
field: fmt.Sprintf("Violations[%v]", idx),
|
||||
reason: "embedded message failed validation",
|
||||
cause: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return ViolationsValidationError{
|
||||
field: fmt.Sprintf("Violations[%v]", idx),
|
||||
reason: "embedded message failed validation",
|
||||
cause: err,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(errors) > 0 {
|
||||
return ViolationsMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ViolationsMultiError is an error wrapping multiple validation errors
|
||||
// returned by Violations.ValidateAll() if the designated constraints aren't met.
|
||||
type ViolationsMultiError []error
|
||||
|
||||
// Error returns a concatenation of all the error messages it wraps.
|
||||
func (m ViolationsMultiError) Error() string {
|
||||
var msgs []string
|
||||
for _, err := range m {
|
||||
msgs = append(msgs, err.Error())
|
||||
}
|
||||
return strings.Join(msgs, "; ")
|
||||
}
|
||||
|
||||
// AllErrors returns a list of validation violation errors.
|
||||
func (m ViolationsMultiError) AllErrors() []error { return m }
|
||||
|
||||
// ViolationsValidationError is the validation error returned by
|
||||
// Violations.Validate if the designated constraints aren't met.
|
||||
type ViolationsValidationError struct {
|
||||
field string
|
||||
reason string
|
||||
cause error
|
||||
key bool
|
||||
}
|
||||
|
||||
// Field function returns field value.
|
||||
func (e ViolationsValidationError) Field() string { return e.field }
|
||||
|
||||
// Reason function returns reason value.
|
||||
func (e ViolationsValidationError) Reason() string { return e.reason }
|
||||
|
||||
// Cause function returns cause value.
|
||||
func (e ViolationsValidationError) Cause() error { return e.cause }
|
||||
|
||||
// Key function returns key value.
|
||||
func (e ViolationsValidationError) Key() bool { return e.key }
|
||||
|
||||
// ErrorName returns error name.
|
||||
func (e ViolationsValidationError) ErrorName() string { return "ViolationsValidationError" }
|
||||
|
||||
// Error satisfies the builtin error interface
|
||||
func (e ViolationsValidationError) Error() string {
|
||||
cause := ""
|
||||
if e.cause != nil {
|
||||
cause = fmt.Sprintf(" | caused by: %v", e.cause)
|
||||
}
|
||||
|
||||
key := ""
|
||||
if e.key {
|
||||
key = "key for "
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"invalid %sViolations.%s: %s%s",
|
||||
key,
|
||||
e.field,
|
||||
e.reason,
|
||||
cause)
|
||||
}
|
||||
|
||||
var _ error = ViolationsValidationError{}
|
||||
|
||||
var _ interface {
|
||||
Field() string
|
||||
Reason() string
|
||||
Key() bool
|
||||
Cause() error
|
||||
ErrorName() string
|
||||
} = ViolationsValidationError{}
|
||||
|
||||
// Validate checks the field values on Violation with the rules defined in the
|
||||
// proto definition for this message. If any rules are violated, the first
|
||||
// error encountered is returned, or nil if there are no violations.
|
||||
func (m *Violation) Validate() error {
|
||||
return m.validate(false)
|
||||
}
|
||||
|
||||
// ValidateAll checks the field values on Violation with the rules defined in
|
||||
// the proto definition for this message. If any rules are violated, the
|
||||
// result is a list of violation errors wrapped in ViolationMultiError, or nil
|
||||
// if none found.
|
||||
func (m *Violation) ValidateAll() error {
|
||||
return m.validate(true)
|
||||
}
|
||||
|
||||
func (m *Violation) validate(all bool) error {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var errors []error
|
||||
|
||||
// no validation rules for FieldPath
|
||||
|
||||
// no validation rules for ConstraintId
|
||||
|
||||
// no validation rules for Message
|
||||
|
||||
// no validation rules for ForKey
|
||||
|
||||
if len(errors) > 0 {
|
||||
return ViolationMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ViolationMultiError is an error wrapping multiple validation errors returned
|
||||
// by Violation.ValidateAll() if the designated constraints aren't met.
|
||||
type ViolationMultiError []error
|
||||
|
||||
// Error returns a concatenation of all the error messages it wraps.
|
||||
func (m ViolationMultiError) Error() string {
|
||||
var msgs []string
|
||||
for _, err := range m {
|
||||
msgs = append(msgs, err.Error())
|
||||
}
|
||||
return strings.Join(msgs, "; ")
|
||||
}
|
||||
|
||||
// AllErrors returns a list of validation violation errors.
|
||||
func (m ViolationMultiError) AllErrors() []error { return m }
|
||||
|
||||
// ViolationValidationError is the validation error returned by
|
||||
// Violation.Validate if the designated constraints aren't met.
|
||||
type ViolationValidationError struct {
|
||||
field string
|
||||
reason string
|
||||
cause error
|
||||
key bool
|
||||
}
|
||||
|
||||
// Field function returns field value.
|
||||
func (e ViolationValidationError) Field() string { return e.field }
|
||||
|
||||
// Reason function returns reason value.
|
||||
func (e ViolationValidationError) Reason() string { return e.reason }
|
||||
|
||||
// Cause function returns cause value.
|
||||
func (e ViolationValidationError) Cause() error { return e.cause }
|
||||
|
||||
// Key function returns key value.
|
||||
func (e ViolationValidationError) Key() bool { return e.key }
|
||||
|
||||
// ErrorName returns error name.
|
||||
func (e ViolationValidationError) ErrorName() string { return "ViolationValidationError" }
|
||||
|
||||
// Error satisfies the builtin error interface
|
||||
func (e ViolationValidationError) Error() string {
|
||||
cause := ""
|
||||
if e.cause != nil {
|
||||
cause = fmt.Sprintf(" | caused by: %v", e.cause)
|
||||
}
|
||||
|
||||
key := ""
|
||||
if e.key {
|
||||
key = "key for "
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"invalid %sViolation.%s: %s%s",
|
||||
key,
|
||||
e.field,
|
||||
e.reason,
|
||||
cause)
|
||||
}
|
||||
|
||||
var _ error = ViolationValidationError{}
|
||||
|
||||
var _ interface {
|
||||
Field() string
|
||||
Reason() string
|
||||
Key() bool
|
||||
Cause() error
|
||||
ErrorName() string
|
||||
} = ViolationValidationError{}
|
||||
|
|
@ -1,289 +0,0 @@
|
|||
// Copyright 2023 Buf Technologies, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.1
|
||||
// protoc (unknown)
|
||||
// source: buf/validate/priv/private.proto
|
||||
|
||||
package priv
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
descriptorpb "google.golang.org/protobuf/types/descriptorpb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// Do not use. Internal to protovalidate library
|
||||
type FieldConstraints struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Cel []*Constraint `protobuf:"bytes,1,rep,name=cel,proto3" json:"cel,omitempty"`
|
||||
}
|
||||
|
||||
func (x *FieldConstraints) Reset() {
|
||||
*x = FieldConstraints{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_buf_validate_priv_private_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *FieldConstraints) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*FieldConstraints) ProtoMessage() {}
|
||||
|
||||
func (x *FieldConstraints) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_buf_validate_priv_private_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use FieldConstraints.ProtoReflect.Descriptor instead.
|
||||
func (*FieldConstraints) Descriptor() ([]byte, []int) {
|
||||
return file_buf_validate_priv_private_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *FieldConstraints) GetCel() []*Constraint {
|
||||
if x != nil {
|
||||
return x.Cel
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Do not use. Internal to protovalidate library
|
||||
type Constraint struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
|
||||
Expression string `protobuf:"bytes,3,opt,name=expression,proto3" json:"expression,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Constraint) Reset() {
|
||||
*x = Constraint{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_buf_validate_priv_private_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Constraint) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Constraint) ProtoMessage() {}
|
||||
|
||||
func (x *Constraint) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_buf_validate_priv_private_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Constraint.ProtoReflect.Descriptor instead.
|
||||
func (*Constraint) Descriptor() ([]byte, []int) {
|
||||
return file_buf_validate_priv_private_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *Constraint) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Constraint) GetMessage() string {
|
||||
if x != nil {
|
||||
return x.Message
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Constraint) GetExpression() string {
|
||||
if x != nil {
|
||||
return x.Expression
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var file_buf_validate_priv_private_proto_extTypes = []protoimpl.ExtensionInfo{
|
||||
{
|
||||
ExtendedType: (*descriptorpb.FieldOptions)(nil),
|
||||
ExtensionType: (*FieldConstraints)(nil),
|
||||
Field: 1160,
|
||||
Name: "buf.validate.priv.field",
|
||||
Tag: "bytes,1160,opt,name=field",
|
||||
Filename: "buf/validate/priv/private.proto",
|
||||
},
|
||||
}
|
||||
|
||||
// Extension fields to descriptorpb.FieldOptions.
|
||||
var (
|
||||
// Do not use. Internal to protovalidate library
|
||||
//
|
||||
// optional buf.validate.priv.FieldConstraints field = 1160;
|
||||
E_Field = &file_buf_validate_priv_private_proto_extTypes[0]
|
||||
)
|
||||
|
||||
var File_buf_validate_priv_private_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_buf_validate_priv_private_proto_rawDesc = []byte{
|
||||
0x0a, 0x1f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x70,
|
||||
0x72, 0x69, 0x76, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x12, 0x11, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x69, 0x76, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x43, 0x0a, 0x10, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43,
|
||||
0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x2f, 0x0a, 0x03, 0x63, 0x65,
|
||||
0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61,
|
||||
0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x76, 0x2e, 0x43, 0x6f, 0x6e, 0x73,
|
||||
0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x52, 0x03, 0x63, 0x65, 0x6c, 0x22, 0x56, 0x0a, 0x0a, 0x43,
|
||||
0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73,
|
||||
0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73,
|
||||
0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f,
|
||||
0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73,
|
||||
0x69, 0x6f, 0x6e, 0x3a, 0x5c, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x1d, 0x2e, 0x67,
|
||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46,
|
||||
0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x88, 0x09, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x23, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74,
|
||||
0x65, 0x2e, 0x70, 0x72, 0x69, 0x76, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x73,
|
||||
0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x88, 0x01,
|
||||
0x01, 0x42, 0xdb, 0x01, 0x0a, 0x17, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2e, 0x62, 0x75, 0x66, 0x2e,
|
||||
0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x76, 0x42, 0x0c, 0x50,
|
||||
0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4c, 0x62,
|
||||
0x75, 0x66, 0x2e, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f,
|
||||
0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61,
|
||||
0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x62,
|
||||
0x75, 0x66, 0x66, 0x65, 0x72, 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61,
|
||||
0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x70, 0x72, 0x69, 0x76, 0xa2, 0x02, 0x03, 0x42, 0x56,
|
||||
0x50, 0xaa, 0x02, 0x11, 0x42, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65,
|
||||
0x2e, 0x50, 0x72, 0x69, 0x76, 0xca, 0x02, 0x11, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69,
|
||||
0x64, 0x61, 0x74, 0x65, 0x5c, 0x50, 0x72, 0x69, 0x76, 0xe2, 0x02, 0x1d, 0x42, 0x75, 0x66, 0x5c,
|
||||
0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x50, 0x72, 0x69, 0x76, 0x5c, 0x47, 0x50,
|
||||
0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x42, 0x75, 0x66, 0x3a,
|
||||
0x3a, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x50, 0x72, 0x69, 0x76, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_buf_validate_priv_private_proto_rawDescOnce sync.Once
|
||||
file_buf_validate_priv_private_proto_rawDescData = file_buf_validate_priv_private_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_buf_validate_priv_private_proto_rawDescGZIP() []byte {
|
||||
file_buf_validate_priv_private_proto_rawDescOnce.Do(func() {
|
||||
file_buf_validate_priv_private_proto_rawDescData = protoimpl.X.CompressGZIP(file_buf_validate_priv_private_proto_rawDescData)
|
||||
})
|
||||
return file_buf_validate_priv_private_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_buf_validate_priv_private_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_buf_validate_priv_private_proto_goTypes = []interface{}{
|
||||
(*FieldConstraints)(nil), // 0: buf.validate.priv.FieldConstraints
|
||||
(*Constraint)(nil), // 1: buf.validate.priv.Constraint
|
||||
(*descriptorpb.FieldOptions)(nil), // 2: google.protobuf.FieldOptions
|
||||
}
|
||||
var file_buf_validate_priv_private_proto_depIdxs = []int32{
|
||||
1, // 0: buf.validate.priv.FieldConstraints.cel:type_name -> buf.validate.priv.Constraint
|
||||
2, // 1: buf.validate.priv.field:extendee -> google.protobuf.FieldOptions
|
||||
0, // 2: buf.validate.priv.field:type_name -> buf.validate.priv.FieldConstraints
|
||||
3, // [3:3] is the sub-list for method output_type
|
||||
3, // [3:3] is the sub-list for method input_type
|
||||
2, // [2:3] is the sub-list for extension type_name
|
||||
1, // [1:2] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_buf_validate_priv_private_proto_init() }
|
||||
func file_buf_validate_priv_private_proto_init() {
|
||||
if File_buf_validate_priv_private_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_buf_validate_priv_private_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*FieldConstraints); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_buf_validate_priv_private_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Constraint); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_buf_validate_priv_private_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 1,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_buf_validate_priv_private_proto_goTypes,
|
||||
DependencyIndexes: file_buf_validate_priv_private_proto_depIdxs,
|
||||
MessageInfos: file_buf_validate_priv_private_proto_msgTypes,
|
||||
ExtensionInfos: file_buf_validate_priv_private_proto_extTypes,
|
||||
}.Build()
|
||||
File_buf_validate_priv_private_proto = out.File
|
||||
file_buf_validate_priv_private_proto_rawDesc = nil
|
||||
file_buf_validate_priv_private_proto_goTypes = nil
|
||||
file_buf_validate_priv_private_proto_depIdxs = nil
|
||||
}
|
||||
|
|
@ -1,275 +0,0 @@
|
|||
// Code generated by protoc-gen-validate. DO NOT EDIT.
|
||||
// source: buf/validate/priv/private.proto
|
||||
|
||||
package priv
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/mail"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"google.golang.org/protobuf/types/known/anypb"
|
||||
)
|
||||
|
||||
// ensure the imports are used
|
||||
var (
|
||||
_ = bytes.MinRead
|
||||
_ = errors.New("")
|
||||
_ = fmt.Print
|
||||
_ = utf8.UTFMax
|
||||
_ = (*regexp.Regexp)(nil)
|
||||
_ = (*strings.Reader)(nil)
|
||||
_ = net.IPv4len
|
||||
_ = time.Duration(0)
|
||||
_ = (*url.URL)(nil)
|
||||
_ = (*mail.Address)(nil)
|
||||
_ = anypb.Any{}
|
||||
_ = sort.Sort
|
||||
)
|
||||
|
||||
// Validate checks the field values on FieldConstraints with the rules defined
|
||||
// in the proto definition for this message. If any rules are violated, the
|
||||
// first error encountered is returned, or nil if there are no violations.
|
||||
func (m *FieldConstraints) Validate() error {
|
||||
return m.validate(false)
|
||||
}
|
||||
|
||||
// ValidateAll checks the field values on FieldConstraints with the rules
|
||||
// defined in the proto definition for this message. If any rules are
|
||||
// violated, the result is a list of violation errors wrapped in
|
||||
// FieldConstraintsMultiError, or nil if none found.
|
||||
func (m *FieldConstraints) ValidateAll() error {
|
||||
return m.validate(true)
|
||||
}
|
||||
|
||||
func (m *FieldConstraints) validate(all bool) error {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var errors []error
|
||||
|
||||
for idx, item := range m.GetCel() {
|
||||
_, _ = idx, item
|
||||
|
||||
if all {
|
||||
switch v := interface{}(item).(type) {
|
||||
case interface{ ValidateAll() error }:
|
||||
if err := v.ValidateAll(); err != nil {
|
||||
errors = append(errors, FieldConstraintsValidationError{
|
||||
field: fmt.Sprintf("Cel[%v]", idx),
|
||||
reason: "embedded message failed validation",
|
||||
cause: err,
|
||||
})
|
||||
}
|
||||
case interface{ Validate() error }:
|
||||
if err := v.Validate(); err != nil {
|
||||
errors = append(errors, FieldConstraintsValidationError{
|
||||
field: fmt.Sprintf("Cel[%v]", idx),
|
||||
reason: "embedded message failed validation",
|
||||
cause: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return FieldConstraintsValidationError{
|
||||
field: fmt.Sprintf("Cel[%v]", idx),
|
||||
reason: "embedded message failed validation",
|
||||
cause: err,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(errors) > 0 {
|
||||
return FieldConstraintsMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// FieldConstraintsMultiError is an error wrapping multiple validation errors
|
||||
// returned by FieldConstraints.ValidateAll() if the designated constraints
|
||||
// aren't met.
|
||||
type FieldConstraintsMultiError []error
|
||||
|
||||
// Error returns a concatenation of all the error messages it wraps.
|
||||
func (m FieldConstraintsMultiError) Error() string {
|
||||
var msgs []string
|
||||
for _, err := range m {
|
||||
msgs = append(msgs, err.Error())
|
||||
}
|
||||
return strings.Join(msgs, "; ")
|
||||
}
|
||||
|
||||
// AllErrors returns a list of validation violation errors.
|
||||
func (m FieldConstraintsMultiError) AllErrors() []error { return m }
|
||||
|
||||
// FieldConstraintsValidationError is the validation error returned by
|
||||
// FieldConstraints.Validate if the designated constraints aren't met.
|
||||
type FieldConstraintsValidationError struct {
|
||||
field string
|
||||
reason string
|
||||
cause error
|
||||
key bool
|
||||
}
|
||||
|
||||
// Field function returns field value.
|
||||
func (e FieldConstraintsValidationError) Field() string { return e.field }
|
||||
|
||||
// Reason function returns reason value.
|
||||
func (e FieldConstraintsValidationError) Reason() string { return e.reason }
|
||||
|
||||
// Cause function returns cause value.
|
||||
func (e FieldConstraintsValidationError) Cause() error { return e.cause }
|
||||
|
||||
// Key function returns key value.
|
||||
func (e FieldConstraintsValidationError) Key() bool { return e.key }
|
||||
|
||||
// ErrorName returns error name.
|
||||
func (e FieldConstraintsValidationError) ErrorName() string { return "FieldConstraintsValidationError" }
|
||||
|
||||
// Error satisfies the builtin error interface
|
||||
func (e FieldConstraintsValidationError) Error() string {
|
||||
cause := ""
|
||||
if e.cause != nil {
|
||||
cause = fmt.Sprintf(" | caused by: %v", e.cause)
|
||||
}
|
||||
|
||||
key := ""
|
||||
if e.key {
|
||||
key = "key for "
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"invalid %sFieldConstraints.%s: %s%s",
|
||||
key,
|
||||
e.field,
|
||||
e.reason,
|
||||
cause)
|
||||
}
|
||||
|
||||
var _ error = FieldConstraintsValidationError{}
|
||||
|
||||
var _ interface {
|
||||
Field() string
|
||||
Reason() string
|
||||
Key() bool
|
||||
Cause() error
|
||||
ErrorName() string
|
||||
} = FieldConstraintsValidationError{}
|
||||
|
||||
// Validate checks the field values on Constraint with the rules defined in the
|
||||
// proto definition for this message. If any rules are violated, the first
|
||||
// error encountered is returned, or nil if there are no violations.
|
||||
func (m *Constraint) Validate() error {
|
||||
return m.validate(false)
|
||||
}
|
||||
|
||||
// ValidateAll checks the field values on Constraint with the rules defined in
|
||||
// the proto definition for this message. If any rules are violated, the
|
||||
// result is a list of violation errors wrapped in ConstraintMultiError, or
|
||||
// nil if none found.
|
||||
func (m *Constraint) ValidateAll() error {
|
||||
return m.validate(true)
|
||||
}
|
||||
|
||||
func (m *Constraint) validate(all bool) error {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var errors []error
|
||||
|
||||
// no validation rules for Id
|
||||
|
||||
// no validation rules for Message
|
||||
|
||||
// no validation rules for Expression
|
||||
|
||||
if len(errors) > 0 {
|
||||
return ConstraintMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ConstraintMultiError is an error wrapping multiple validation errors
|
||||
// returned by Constraint.ValidateAll() if the designated constraints aren't met.
|
||||
type ConstraintMultiError []error
|
||||
|
||||
// Error returns a concatenation of all the error messages it wraps.
|
||||
func (m ConstraintMultiError) Error() string {
|
||||
var msgs []string
|
||||
for _, err := range m {
|
||||
msgs = append(msgs, err.Error())
|
||||
}
|
||||
return strings.Join(msgs, "; ")
|
||||
}
|
||||
|
||||
// AllErrors returns a list of validation violation errors.
|
||||
func (m ConstraintMultiError) AllErrors() []error { return m }
|
||||
|
||||
// ConstraintValidationError is the validation error returned by
|
||||
// Constraint.Validate if the designated constraints aren't met.
|
||||
type ConstraintValidationError struct {
|
||||
field string
|
||||
reason string
|
||||
cause error
|
||||
key bool
|
||||
}
|
||||
|
||||
// Field function returns field value.
|
||||
func (e ConstraintValidationError) Field() string { return e.field }
|
||||
|
||||
// Reason function returns reason value.
|
||||
func (e ConstraintValidationError) Reason() string { return e.reason }
|
||||
|
||||
// Cause function returns cause value.
|
||||
func (e ConstraintValidationError) Cause() error { return e.cause }
|
||||
|
||||
// Key function returns key value.
|
||||
func (e ConstraintValidationError) Key() bool { return e.key }
|
||||
|
||||
// ErrorName returns error name.
|
||||
func (e ConstraintValidationError) ErrorName() string { return "ConstraintValidationError" }
|
||||
|
||||
// Error satisfies the builtin error interface
|
||||
func (e ConstraintValidationError) Error() string {
|
||||
cause := ""
|
||||
if e.cause != nil {
|
||||
cause = fmt.Sprintf(" | caused by: %v", e.cause)
|
||||
}
|
||||
|
||||
key := ""
|
||||
if e.key {
|
||||
key = "key for "
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"invalid %sConstraint.%s: %s%s",
|
||||
key,
|
||||
e.field,
|
||||
e.reason,
|
||||
cause)
|
||||
}
|
||||
|
||||
var _ error = ConstraintValidationError{}
|
||||
|
||||
var _ interface {
|
||||
Field() string
|
||||
Reason() string
|
||||
Key() bool
|
||||
Cause() error
|
||||
ErrorName() string
|
||||
} = ConstraintValidationError{}
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,15 +1,11 @@
|
|||
version: v2
|
||||
managed:
|
||||
enabled: true
|
||||
override:
|
||||
- file_option: java_package_prefix
|
||||
value: ""
|
||||
plugins:
|
||||
- remote: buf.build/protocolbuffers/go:v1.34.1
|
||||
- local: protoc-gen-go
|
||||
out: ../gen/go
|
||||
opt:
|
||||
- paths=source_relative
|
||||
- remote: buf.build/bufbuild/validate-go:v1.0.4
|
||||
- local: protoc-gen-validate
|
||||
out: ../gen/go
|
||||
opt:
|
||||
- paths=source_relative
|
||||
- paths=source_relative
|
||||
- lang=go
|
||||
|
|
@ -4,5 +4,5 @@ deps:
|
|||
- remote: buf.build
|
||||
owner: bufbuild
|
||||
repository: protovalidate
|
||||
commit: 46a4cf4ba1094a34bcd89a6c67163b4b
|
||||
digest: shake256:436ce453801917c11bc7b21d66bcfae87da2aceb804a041487be1e51dc9fbc219e61ea6a552db7a7aa6d63bb5efd0f3ed5fe3d4c42d4f750d0eb35f14144e3b6
|
||||
commit: a6c49f84cc0f4e038680d390392e2ab0
|
||||
digest: shake256:3deb629c655e469d87c58babcfbed403275a741fb4a269366c4fd6ea9db012cf562a1e64819508d73670c506f96d01f724c43bc97b44e2e02aa6e8bbdd160ab2
|
||||
|
|
|
|||
Loading…
Reference in a new issue