diff --git a/proto/protovalidate-testing/buf/validate/conformance/cases/BUILD.bazel b/proto/protovalidate-testing/buf/validate/conformance/cases/BUILD.bazel index 4d78c948..0944415e 100644 --- a/proto/protovalidate-testing/buf/validate/conformance/cases/BUILD.bazel +++ b/proto/protovalidate-testing/buf/validate/conformance/cases/BUILD.bazel @@ -28,6 +28,8 @@ proto_library( "numbers.proto", "oneofs.proto", "repeated.proto", + "required_field_proto2.proto", + "required_field_proto3.proto", "strings.proto", "wkt_any.proto", "wkt_duration.proto", diff --git a/proto/protovalidate-testing/buf/validate/conformance/cases/oneofs.proto b/proto/protovalidate-testing/buf/validate/conformance/cases/oneofs.proto index b9a87438..37a0d875 100644 --- a/proto/protovalidate-testing/buf/validate/conformance/cases/oneofs.proto +++ b/proto/protovalidate-testing/buf/validate/conformance/cases/oneofs.proto @@ -48,6 +48,15 @@ message OneofRequired { } } +message OneofRequiredWithRequiredField { + oneof o { + option (buf.validate.oneof).required = true; + + string a = 1 [(buf.validate.field).required = true]; + string b = 2; + } +} + message OneofIgnoreEmpty { oneof o { string x = 1 [ @@ -66,8 +75,8 @@ message OneofIgnoreEmpty { ]; int32 z = 3 [ (buf.validate.field).int32 = { - lte: 128, - gte: 256, + gte: 128, + lte: 256, }, (buf.validate.field).ignore_empty = true ]; diff --git a/proto/protovalidate-testing/buf/validate/conformance/cases/required_field_proto2.proto b/proto/protovalidate-testing/buf/validate/conformance/cases/required_field_proto2.proto new file mode 100644 index 00000000..ef86bce0 --- /dev/null +++ b/proto/protovalidate-testing/buf/validate/conformance/cases/required_field_proto2.proto @@ -0,0 +1,56 @@ +// 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. + +syntax = "proto2"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message RequiredProto2ScalarOptional { + optional string val = 1 [(buf.validate.field).required = true]; +} + +message RequiredProto2ScalarOptionalDefault { + optional string val = 1 [ + (buf.validate.field).required = true, + default = "foo" + ]; +} + +message RequiredProto2ScalarRequired { + required string val = 1 [(buf.validate.field).required = true]; +} + +message RequiredProto2Message { + optional Msg val = 1 [(buf.validate.field).required = true]; + message Msg { + optional string val = 1; + } +} + +message RequiredProto2Oneof { + oneof val { + string a = 1 [(buf.validate.field).required = true]; + string b = 2; + } +} + +message RequiredProto2Repeated { + repeated string val = 1 [(buf.validate.field).required = true]; +} + +message RequiredProto2Map { + map val = 1 [(buf.validate.field).required = true]; +} diff --git a/proto/protovalidate-testing/buf/validate/conformance/cases/required_field_proto3.proto b/proto/protovalidate-testing/buf/validate/conformance/cases/required_field_proto3.proto new file mode 100644 index 00000000..0c883da3 --- /dev/null +++ b/proto/protovalidate-testing/buf/validate/conformance/cases/required_field_proto3.proto @@ -0,0 +1,49 @@ +// 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. + +syntax = "proto3"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message RequiredProto3Scalar { + string val = 1 [(buf.validate.field).required = true]; +} + +message RequiredProto3OptionalScalar { + optional string val = 1 [(buf.validate.field).required = true]; +} + +message RequiredProto3Message { + Msg val = 1 [(buf.validate.field).required = true]; + message Msg { + string val = 1; + } +} + +message RequiredProto3OneOf { + oneof val { + string a = 1 [(buf.validate.field).required = true]; + string b = 2; + } +} + +message RequiredProto3Repeated { + repeated string val = 1 [(buf.validate.field).required = true]; +} + +message RequiredProto3Map { + map val = 1 [(buf.validate.field).required = true]; +} diff --git a/proto/protovalidate/buf/validate/validate.proto b/proto/protovalidate/buf/validate/validate.proto index 9b4c7b4f..35d65b76 100644 --- a/proto/protovalidate/buf/validate/validate.proto +++ b/proto/protovalidate/buf/validate/validate.proto @@ -91,21 +91,22 @@ message MessageConstraints { } // The `OneofConstraints` message type enables you to manage constraints for -// oneof fields in your protobuf messages. Use the `required` constraint to ensure -// that exactly one of the fields within a oneof is set; validation will fail -// if none of the fields in the oneof are set: +// oneof fields in your protobuf messages. message OneofConstraints { - // `required` is an optional boolean attribute that ensures that - // exactly one of the field options in a oneof is set; validation fails if - // no fields in the oneof are set. + // If `required` is true, exactly one field of the oneof must be present. A + // validation error is returned if no fields in the oneof are present. The + // field itself may still be a default value; further constraints + // should be placed on the fields themselves to ensure they are valid values, + // such as `min_len` or `gt`. // // ```proto // message MyMessage { // oneof value { - // // The field `a` or `b` must be set. + // // Either `a` or `b` must be set. If `a` is set, it must also be + // // non-empty; whereas if `b` is set, it can still be an empty string. // option (buf.validate.oneof).required = true; - // optional string a = 1; - // optional string b = 2; + // string a = 1 [(buf.validate.field).string.min_len = 1]; + // string b = 2; // } // } // ``` @@ -141,28 +142,37 @@ message FieldConstraints { // } // ``` bool skipped = 24; - // `required` is an optional boolean attribute that specifies that - // this field must be set. If required is set to true, the field value must - // not be empty; otherwise, an error message will be generated. + // If `required` is true, the field must be populated. Field presence can be + // described as "serialized in the wire format," which follows the following rules: // - // Note that `required` validates that `repeated` fields are non-empty, that is - // setting a `repeated` field as `required` is equivalent to `repeated.min_items = 1`. + // - the following "nullable" fields must be explicitly set to be considered present: + // - singular message fields (may be their empty value) + // - member fields of a oneof (may be their default value) + // - proto3 optional fields (may be their default value) + // - proto2 scalar fields + // - proto3 scalar fields must be non-zero to be considered present + // - repeated and map fields must be non-empty to be considered present // // ```proto // message MyMessage { - // // The field `value` must be set. + // // The field `value` must be set to a non-null value. // optional MyOtherMessage value = 1 [(buf.validate.field).required = true]; // } // ``` bool required = 25; - // `ignore_empty` specifies that the validation rules of this field should be - // evaluated only if the field isn't empty. If the field is empty, no validation - // rules are applied. + // If `ignore_empty` is true and applied to a non-nullable field (see + // `required` for more details), validation is skipped on the field if it is + // the default or empty value. Adding `ignore_empty` to a "nullable" field is + // a noop as these unset fields already skip validation (with the exception + // of `required`). // // ```proto // message MyRepeated { - // // The field `value` validation rules should be evaluated only if the field isn't empty. - // repeated string value = 1 [(buf.validate.field).ignore_empty = true]; + // // The field `value` min_len rule is only applied if the field isn't empty. + // repeated string value = 1 [ + // (buf.validate.field).ignore_empty = true, + // (buf.validate.field).min_len = 5 + // ]; // } // ``` bool ignore_empty = 26; diff --git a/tools/internal/gen/buf/validate/conformance/cases/oneofs.pb.go b/tools/internal/gen/buf/validate/conformance/cases/oneofs.pb.go index c69208cc..fec9f9dc 100644 --- a/tools/internal/gen/buf/validate/conformance/cases/oneofs.pb.go +++ b/tools/internal/gen/buf/validate/conformance/cases/oneofs.pb.go @@ -367,6 +367,87 @@ func (*OneofRequired_NameWithUnderscores) isOneofRequired_O() {} func (*OneofRequired_UnderAnd_1Number) isOneofRequired_O() {} +type OneofRequiredWithRequiredField struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to O: + // + // *OneofRequiredWithRequiredField_A + // *OneofRequiredWithRequiredField_B + O isOneofRequiredWithRequiredField_O `protobuf_oneof:"o"` +} + +func (x *OneofRequiredWithRequiredField) Reset() { + *x = OneofRequiredWithRequiredField{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_oneofs_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OneofRequiredWithRequiredField) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OneofRequiredWithRequiredField) ProtoMessage() {} + +func (x *OneofRequiredWithRequiredField) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_oneofs_proto_msgTypes[4] + 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 OneofRequiredWithRequiredField.ProtoReflect.Descriptor instead. +func (*OneofRequiredWithRequiredField) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_oneofs_proto_rawDescGZIP(), []int{4} +} + +func (m *OneofRequiredWithRequiredField) GetO() isOneofRequiredWithRequiredField_O { + if m != nil { + return m.O + } + return nil +} + +func (x *OneofRequiredWithRequiredField) GetA() string { + if x, ok := x.GetO().(*OneofRequiredWithRequiredField_A); ok { + return x.A + } + return "" +} + +func (x *OneofRequiredWithRequiredField) GetB() string { + if x, ok := x.GetO().(*OneofRequiredWithRequiredField_B); ok { + return x.B + } + return "" +} + +type isOneofRequiredWithRequiredField_O interface { + isOneofRequiredWithRequiredField_O() +} + +type OneofRequiredWithRequiredField_A struct { + A string `protobuf:"bytes,1,opt,name=a,proto3,oneof"` +} + +type OneofRequiredWithRequiredField_B struct { + B string `protobuf:"bytes,2,opt,name=b,proto3,oneof"` +} + +func (*OneofRequiredWithRequiredField_A) isOneofRequiredWithRequiredField_O() {} + +func (*OneofRequiredWithRequiredField_B) isOneofRequiredWithRequiredField_O() {} + type OneofIgnoreEmpty struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -383,7 +464,7 @@ type OneofIgnoreEmpty struct { func (x *OneofIgnoreEmpty) Reset() { *x = OneofIgnoreEmpty{} if protoimpl.UnsafeEnabled { - mi := &file_buf_validate_conformance_cases_oneofs_proto_msgTypes[4] + mi := &file_buf_validate_conformance_cases_oneofs_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -396,7 +477,7 @@ func (x *OneofIgnoreEmpty) String() string { func (*OneofIgnoreEmpty) ProtoMessage() {} func (x *OneofIgnoreEmpty) ProtoReflect() protoreflect.Message { - mi := &file_buf_validate_conformance_cases_oneofs_proto_msgTypes[4] + mi := &file_buf_validate_conformance_cases_oneofs_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -409,7 +490,7 @@ func (x *OneofIgnoreEmpty) ProtoReflect() protoreflect.Message { // Deprecated: Use OneofIgnoreEmpty.ProtoReflect.Descriptor instead. func (*OneofIgnoreEmpty) Descriptor() ([]byte, []int) { - return file_buf_validate_conformance_cases_oneofs_proto_rawDescGZIP(), []int{4} + return file_buf_validate_conformance_cases_oneofs_proto_rawDescGZIP(), []int{5} } func (m *OneofIgnoreEmpty) GetO() isOneofIgnoreEmpty_O { @@ -495,33 +576,39 @@ var file_buf_validate_conformance_cases_oneofs_proto_rawDesc = []byte{ 0x12, 0x2d, 0x0a, 0x12, 0x75, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x61, 0x6e, 0x64, 0x5f, 0x31, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x0f, 0x75, 0x6e, 0x64, 0x65, 0x72, 0x41, 0x6e, 0x64, 0x31, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x42, - 0x0a, 0x0a, 0x01, 0x6f, 0x12, 0x05, 0xba, 0x48, 0x02, 0x08, 0x01, 0x22, 0x73, 0x0a, 0x10, 0x4f, - 0x6e, 0x65, 0x6f, 0x66, 0x49, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, - 0x1c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0c, 0xba, 0x48, 0x09, 0xd0, - 0x01, 0x01, 0x72, 0x04, 0x10, 0x03, 0x18, 0x05, 0x48, 0x00, 0x52, 0x01, 0x78, 0x12, 0x1c, 0x0a, - 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0c, 0xba, 0x48, 0x09, 0xd0, 0x01, 0x01, - 0x7a, 0x04, 0x10, 0x03, 0x18, 0x05, 0x48, 0x00, 0x52, 0x01, 0x79, 0x12, 0x1e, 0x0a, 0x01, 0x7a, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x42, 0x0e, 0xba, 0x48, 0x0b, 0xd0, 0x01, 0x01, 0x1a, 0x06, - 0x18, 0x80, 0x01, 0x28, 0x80, 0x02, 0x48, 0x00, 0x52, 0x01, 0x7a, 0x42, 0x03, 0x0a, 0x01, 0x6f, - 0x42, 0xa2, 0x02, 0x0a, 0x22, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, - 0x65, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x42, 0x0b, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x73, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x53, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2f, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x62, 0x75, 0x66, - 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, - 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0xa2, 0x02, 0x04, 0x42, 0x56, - 0x43, 0x43, 0xaa, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x43, 0x61, - 0x73, 0x65, 0x73, 0xca, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x5c, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x5c, 0x43, - 0x61, 0x73, 0x65, 0x73, 0xe2, 0x02, 0x2a, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x5c, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x5c, - 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0xea, 0x02, 0x21, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x65, 0x3a, 0x3a, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x3a, 0x3a, - 0x43, 0x61, 0x73, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0a, 0x0a, 0x01, 0x6f, 0x12, 0x05, 0xba, 0x48, 0x02, 0x08, 0x01, 0x22, 0x54, 0x0a, 0x1e, 0x4f, + 0x6e, 0x65, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x57, 0x69, 0x74, 0x68, + 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x16, 0x0a, + 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, + 0x48, 0x00, 0x52, 0x01, 0x61, 0x12, 0x0e, 0x0a, 0x01, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x48, 0x00, 0x52, 0x01, 0x62, 0x42, 0x0a, 0x0a, 0x01, 0x6f, 0x12, 0x05, 0xba, 0x48, 0x02, 0x08, + 0x01, 0x22, 0x73, 0x0a, 0x10, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x49, 0x67, 0x6e, 0x6f, 0x72, 0x65, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x1c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x0c, 0xba, 0x48, 0x09, 0xd0, 0x01, 0x01, 0x72, 0x04, 0x10, 0x03, 0x18, 0x05, 0x48, 0x00, + 0x52, 0x01, 0x78, 0x12, 0x1c, 0x0a, 0x01, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0c, + 0xba, 0x48, 0x09, 0xd0, 0x01, 0x01, 0x7a, 0x04, 0x10, 0x03, 0x18, 0x05, 0x48, 0x00, 0x52, 0x01, + 0x79, 0x12, 0x1e, 0x0a, 0x01, 0x7a, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x42, 0x0e, 0xba, 0x48, + 0x0b, 0xd0, 0x01, 0x01, 0x1a, 0x06, 0x18, 0x80, 0x02, 0x28, 0x80, 0x01, 0x48, 0x00, 0x52, 0x01, + 0x7a, 0x42, 0x03, 0x0a, 0x01, 0x6f, 0x42, 0xa2, 0x02, 0x0a, 0x22, 0x63, 0x6f, 0x6d, 0x2e, 0x62, + 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x63, 0x6f, 0x6e, 0x66, + 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x42, 0x0b, 0x4f, + 0x6e, 0x65, 0x6f, 0x66, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x53, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, + 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, + 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, + 0x65, 0x6e, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, + 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2f, 0x63, 0x61, 0x73, 0x65, + 0x73, 0xa2, 0x02, 0x04, 0x42, 0x56, 0x43, 0x43, 0xaa, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x2e, 0x56, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, + 0x6e, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0xca, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x5c, + 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, + 0x61, 0x6e, 0x63, 0x65, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0xe2, 0x02, 0x2a, 0x42, 0x75, 0x66, + 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, + 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x21, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x56, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, + 0x61, 0x6e, 0x63, 0x65, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -536,13 +623,14 @@ func file_buf_validate_conformance_cases_oneofs_proto_rawDescGZIP() []byte { return file_buf_validate_conformance_cases_oneofs_proto_rawDescData } -var file_buf_validate_conformance_cases_oneofs_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_buf_validate_conformance_cases_oneofs_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_buf_validate_conformance_cases_oneofs_proto_goTypes = []interface{}{ - (*TestOneofMsg)(nil), // 0: buf.validate.conformance.cases.TestOneofMsg - (*OneofNone)(nil), // 1: buf.validate.conformance.cases.OneofNone - (*Oneof)(nil), // 2: buf.validate.conformance.cases.Oneof - (*OneofRequired)(nil), // 3: buf.validate.conformance.cases.OneofRequired - (*OneofIgnoreEmpty)(nil), // 4: buf.validate.conformance.cases.OneofIgnoreEmpty + (*TestOneofMsg)(nil), // 0: buf.validate.conformance.cases.TestOneofMsg + (*OneofNone)(nil), // 1: buf.validate.conformance.cases.OneofNone + (*Oneof)(nil), // 2: buf.validate.conformance.cases.Oneof + (*OneofRequired)(nil), // 3: buf.validate.conformance.cases.OneofRequired + (*OneofRequiredWithRequiredField)(nil), // 4: buf.validate.conformance.cases.OneofRequiredWithRequiredField + (*OneofIgnoreEmpty)(nil), // 5: buf.validate.conformance.cases.OneofIgnoreEmpty } var file_buf_validate_conformance_cases_oneofs_proto_depIdxs = []int32{ 0, // 0: buf.validate.conformance.cases.Oneof.z:type_name -> buf.validate.conformance.cases.TestOneofMsg @@ -608,6 +696,18 @@ func file_buf_validate_conformance_cases_oneofs_proto_init() { } } file_buf_validate_conformance_cases_oneofs_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OneofRequiredWithRequiredField); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_oneofs_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*OneofIgnoreEmpty); i { case 0: return &v.state @@ -636,6 +736,10 @@ func file_buf_validate_conformance_cases_oneofs_proto_init() { (*OneofRequired_UnderAnd_1Number)(nil), } file_buf_validate_conformance_cases_oneofs_proto_msgTypes[4].OneofWrappers = []interface{}{ + (*OneofRequiredWithRequiredField_A)(nil), + (*OneofRequiredWithRequiredField_B)(nil), + } + file_buf_validate_conformance_cases_oneofs_proto_msgTypes[5].OneofWrappers = []interface{}{ (*OneofIgnoreEmpty_X)(nil), (*OneofIgnoreEmpty_Y)(nil), (*OneofIgnoreEmpty_Z)(nil), @@ -646,7 +750,7 @@ func file_buf_validate_conformance_cases_oneofs_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_buf_validate_conformance_cases_oneofs_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/tools/internal/gen/buf/validate/conformance/cases/required_field_proto2.pb.go b/tools/internal/gen/buf/validate/conformance/cases/required_field_proto2.pb.go new file mode 100644 index 00000000..e74f4cb8 --- /dev/null +++ b/tools/internal/gen/buf/validate/conformance/cases/required_field_proto2.pb.go @@ -0,0 +1,682 @@ +// 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.31.0 +// protoc (unknown) +// source: buf/validate/conformance/cases/required_field_proto2.proto + +package cases + +import ( + _ "github.com/bufbuild/protovalidate/tools/internal/gen/buf/validate" + 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) +) + +type RequiredProto2ScalarOptional struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Val *string `protobuf:"bytes,1,opt,name=val" json:"val,omitempty"` +} + +func (x *RequiredProto2ScalarOptional) Reset() { + *x = RequiredProto2ScalarOptional{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto2ScalarOptional) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto2ScalarOptional) ProtoMessage() {} + +func (x *RequiredProto2ScalarOptional) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto2_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 RequiredProto2ScalarOptional.ProtoReflect.Descriptor instead. +func (*RequiredProto2ScalarOptional) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescGZIP(), []int{0} +} + +func (x *RequiredProto2ScalarOptional) GetVal() string { + if x != nil && x.Val != nil { + return *x.Val + } + return "" +} + +type RequiredProto2ScalarOptionalDefault struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Val *string `protobuf:"bytes,1,opt,name=val,def=foo" json:"val,omitempty"` +} + +// Default values for RequiredProto2ScalarOptionalDefault fields. +const ( + Default_RequiredProto2ScalarOptionalDefault_Val = string("foo") +) + +func (x *RequiredProto2ScalarOptionalDefault) Reset() { + *x = RequiredProto2ScalarOptionalDefault{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto2ScalarOptionalDefault) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto2ScalarOptionalDefault) ProtoMessage() {} + +func (x *RequiredProto2ScalarOptionalDefault) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto2_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 RequiredProto2ScalarOptionalDefault.ProtoReflect.Descriptor instead. +func (*RequiredProto2ScalarOptionalDefault) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescGZIP(), []int{1} +} + +func (x *RequiredProto2ScalarOptionalDefault) GetVal() string { + if x != nil && x.Val != nil { + return *x.Val + } + return Default_RequiredProto2ScalarOptionalDefault_Val +} + +type RequiredProto2ScalarRequired struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Val *string `protobuf:"bytes,1,req,name=val" json:"val,omitempty"` +} + +func (x *RequiredProto2ScalarRequired) Reset() { + *x = RequiredProto2ScalarRequired{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto2ScalarRequired) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto2ScalarRequired) ProtoMessage() {} + +func (x *RequiredProto2ScalarRequired) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto2_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 RequiredProto2ScalarRequired.ProtoReflect.Descriptor instead. +func (*RequiredProto2ScalarRequired) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescGZIP(), []int{2} +} + +func (x *RequiredProto2ScalarRequired) GetVal() string { + if x != nil && x.Val != nil { + return *x.Val + } + return "" +} + +type RequiredProto2Message struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Val *RequiredProto2Message_Msg `protobuf:"bytes,1,opt,name=val" json:"val,omitempty"` +} + +func (x *RequiredProto2Message) Reset() { + *x = RequiredProto2Message{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto2Message) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto2Message) ProtoMessage() {} + +func (x *RequiredProto2Message) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[3] + 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 RequiredProto2Message.ProtoReflect.Descriptor instead. +func (*RequiredProto2Message) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescGZIP(), []int{3} +} + +func (x *RequiredProto2Message) GetVal() *RequiredProto2Message_Msg { + if x != nil { + return x.Val + } + return nil +} + +type RequiredProto2Oneof struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Val: + // + // *RequiredProto2Oneof_A + // *RequiredProto2Oneof_B + Val isRequiredProto2Oneof_Val `protobuf_oneof:"val"` +} + +func (x *RequiredProto2Oneof) Reset() { + *x = RequiredProto2Oneof{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto2Oneof) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto2Oneof) ProtoMessage() {} + +func (x *RequiredProto2Oneof) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[4] + 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 RequiredProto2Oneof.ProtoReflect.Descriptor instead. +func (*RequiredProto2Oneof) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescGZIP(), []int{4} +} + +func (m *RequiredProto2Oneof) GetVal() isRequiredProto2Oneof_Val { + if m != nil { + return m.Val + } + return nil +} + +func (x *RequiredProto2Oneof) GetA() string { + if x, ok := x.GetVal().(*RequiredProto2Oneof_A); ok { + return x.A + } + return "" +} + +func (x *RequiredProto2Oneof) GetB() string { + if x, ok := x.GetVal().(*RequiredProto2Oneof_B); ok { + return x.B + } + return "" +} + +type isRequiredProto2Oneof_Val interface { + isRequiredProto2Oneof_Val() +} + +type RequiredProto2Oneof_A struct { + A string `protobuf:"bytes,1,opt,name=a,oneof"` +} + +type RequiredProto2Oneof_B struct { + B string `protobuf:"bytes,2,opt,name=b,oneof"` +} + +func (*RequiredProto2Oneof_A) isRequiredProto2Oneof_Val() {} + +func (*RequiredProto2Oneof_B) isRequiredProto2Oneof_Val() {} + +type RequiredProto2Repeated struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Val []string `protobuf:"bytes,1,rep,name=val" json:"val,omitempty"` +} + +func (x *RequiredProto2Repeated) Reset() { + *x = RequiredProto2Repeated{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto2Repeated) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto2Repeated) ProtoMessage() {} + +func (x *RequiredProto2Repeated) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[5] + 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 RequiredProto2Repeated.ProtoReflect.Descriptor instead. +func (*RequiredProto2Repeated) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescGZIP(), []int{5} +} + +func (x *RequiredProto2Repeated) GetVal() []string { + if x != nil { + return x.Val + } + return nil +} + +type RequiredProto2Map struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Val map[string]string `protobuf:"bytes,1,rep,name=val" json:"val,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` +} + +func (x *RequiredProto2Map) Reset() { + *x = RequiredProto2Map{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto2Map) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto2Map) ProtoMessage() {} + +func (x *RequiredProto2Map) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[6] + 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 RequiredProto2Map.ProtoReflect.Descriptor instead. +func (*RequiredProto2Map) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescGZIP(), []int{6} +} + +func (x *RequiredProto2Map) GetVal() map[string]string { + if x != nil { + return x.Val + } + return nil +} + +type RequiredProto2Message_Msg struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Val *string `protobuf:"bytes,1,opt,name=val" json:"val,omitempty"` +} + +func (x *RequiredProto2Message_Msg) Reset() { + *x = RequiredProto2Message_Msg{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto2Message_Msg) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto2Message_Msg) ProtoMessage() {} + +func (x *RequiredProto2Message_Msg) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[7] + 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 RequiredProto2Message_Msg.ProtoReflect.Descriptor instead. +func (*RequiredProto2Message_Msg) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescGZIP(), []int{3, 0} +} + +func (x *RequiredProto2Message_Msg) GetVal() string { + if x != nil && x.Val != nil { + return *x.Val + } + return "" +} + +var File_buf_validate_conformance_cases_required_field_proto2_proto protoreflect.FileDescriptor + +var file_buf_validate_conformance_cases_required_field_proto2_proto_rawDesc = []byte{ + 0x0a, 0x3a, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x63, + 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, + 0x2f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x62, 0x75, + 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x6f, + 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x1a, 0x1b, 0x62, 0x75, + 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x38, 0x0a, 0x1c, 0x52, 0x65, 0x71, + 0x75, 0x69, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x53, 0x63, 0x61, 0x6c, 0x61, + 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x12, 0x18, 0x0a, 0x03, 0x76, 0x61, 0x6c, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x03, + 0x76, 0x61, 0x6c, 0x22, 0x44, 0x0a, 0x23, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x53, 0x63, 0x61, 0x6c, 0x61, 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x61, 0x6c, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x1d, 0x0a, 0x03, 0x76, 0x61, + 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x3a, 0x03, 0x66, 0x6f, 0x6f, 0x42, 0x06, 0xba, 0x48, + 0x03, 0xc8, 0x01, 0x01, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0x38, 0x0a, 0x1c, 0x52, 0x65, 0x71, + 0x75, 0x69, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x53, 0x63, 0x61, 0x6c, 0x61, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x12, 0x18, 0x0a, 0x03, 0x76, 0x61, 0x6c, + 0x18, 0x01, 0x20, 0x02, 0x28, 0x09, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x03, + 0x76, 0x61, 0x6c, 0x22, 0x85, 0x01, 0x0a, 0x15, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x53, 0x0a, + 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x39, 0x2e, 0x62, 0x75, 0x66, + 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, + 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x71, 0x75, + 0x69, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x4d, 0x73, 0x67, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x03, 0x76, + 0x61, 0x6c, 0x1a, 0x17, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0x44, 0x0a, 0x13, 0x52, + 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x4f, 0x6e, 0x65, + 0x6f, 0x66, 0x12, 0x16, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xba, + 0x48, 0x03, 0xc8, 0x01, 0x01, 0x48, 0x00, 0x52, 0x01, 0x61, 0x12, 0x0e, 0x0a, 0x01, 0x62, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x01, 0x62, 0x42, 0x05, 0x0a, 0x03, 0x76, 0x61, + 0x6c, 0x22, 0x32, 0x0a, 0x16, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x32, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x18, 0x0a, 0x03, 0x76, + 0x61, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, + 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0xa1, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, + 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x4d, 0x61, 0x70, 0x12, 0x54, 0x0a, 0x03, 0x76, + 0x61, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, + 0x6e, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, + 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x4d, 0x61, 0x70, 0x2e, 0x56, 0x61, 0x6c, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x03, 0x76, 0x61, + 0x6c, 0x1a, 0x36, 0x0a, 0x08, 0x56, 0x61, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0xaf, 0x02, 0x0a, 0x22, 0x63, 0x6f, + 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x63, + 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, + 0x42, 0x18, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x53, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, + 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, + 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, + 0x65, 0x6e, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, + 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2f, 0x63, 0x61, 0x73, 0x65, + 0x73, 0xa2, 0x02, 0x04, 0x42, 0x56, 0x43, 0x43, 0xaa, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x2e, 0x56, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, + 0x6e, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0xca, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x5c, + 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, + 0x61, 0x6e, 0x63, 0x65, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0xe2, 0x02, 0x2a, 0x42, 0x75, 0x66, + 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, + 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x21, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x56, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, + 0x61, 0x6e, 0x63, 0x65, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, +} + +var ( + file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescOnce sync.Once + file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescData = file_buf_validate_conformance_cases_required_field_proto2_proto_rawDesc +) + +func file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescGZIP() []byte { + file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescOnce.Do(func() { + file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescData = protoimpl.X.CompressGZIP(file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescData) + }) + return file_buf_validate_conformance_cases_required_field_proto2_proto_rawDescData +} + +var file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_buf_validate_conformance_cases_required_field_proto2_proto_goTypes = []interface{}{ + (*RequiredProto2ScalarOptional)(nil), // 0: buf.validate.conformance.cases.RequiredProto2ScalarOptional + (*RequiredProto2ScalarOptionalDefault)(nil), // 1: buf.validate.conformance.cases.RequiredProto2ScalarOptionalDefault + (*RequiredProto2ScalarRequired)(nil), // 2: buf.validate.conformance.cases.RequiredProto2ScalarRequired + (*RequiredProto2Message)(nil), // 3: buf.validate.conformance.cases.RequiredProto2Message + (*RequiredProto2Oneof)(nil), // 4: buf.validate.conformance.cases.RequiredProto2Oneof + (*RequiredProto2Repeated)(nil), // 5: buf.validate.conformance.cases.RequiredProto2Repeated + (*RequiredProto2Map)(nil), // 6: buf.validate.conformance.cases.RequiredProto2Map + (*RequiredProto2Message_Msg)(nil), // 7: buf.validate.conformance.cases.RequiredProto2Message.Msg + nil, // 8: buf.validate.conformance.cases.RequiredProto2Map.ValEntry +} +var file_buf_validate_conformance_cases_required_field_proto2_proto_depIdxs = []int32{ + 7, // 0: buf.validate.conformance.cases.RequiredProto2Message.val:type_name -> buf.validate.conformance.cases.RequiredProto2Message.Msg + 8, // 1: buf.validate.conformance.cases.RequiredProto2Map.val:type_name -> buf.validate.conformance.cases.RequiredProto2Map.ValEntry + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_buf_validate_conformance_cases_required_field_proto2_proto_init() } +func file_buf_validate_conformance_cases_required_field_proto2_proto_init() { + if File_buf_validate_conformance_cases_required_field_proto2_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto2ScalarOptional); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto2ScalarOptionalDefault); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto2ScalarRequired); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto2Message); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto2Oneof); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto2Repeated); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto2Map); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto2Message_Msg); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes[4].OneofWrappers = []interface{}{ + (*RequiredProto2Oneof_A)(nil), + (*RequiredProto2Oneof_B)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_buf_validate_conformance_cases_required_field_proto2_proto_rawDesc, + NumEnums: 0, + NumMessages: 9, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_buf_validate_conformance_cases_required_field_proto2_proto_goTypes, + DependencyIndexes: file_buf_validate_conformance_cases_required_field_proto2_proto_depIdxs, + MessageInfos: file_buf_validate_conformance_cases_required_field_proto2_proto_msgTypes, + }.Build() + File_buf_validate_conformance_cases_required_field_proto2_proto = out.File + file_buf_validate_conformance_cases_required_field_proto2_proto_rawDesc = nil + file_buf_validate_conformance_cases_required_field_proto2_proto_goTypes = nil + file_buf_validate_conformance_cases_required_field_proto2_proto_depIdxs = nil +} diff --git a/tools/internal/gen/buf/validate/conformance/cases/required_field_proto3.pb.go b/tools/internal/gen/buf/validate/conformance/cases/required_field_proto3.pb.go new file mode 100644 index 00000000..821ee6cb --- /dev/null +++ b/tools/internal/gen/buf/validate/conformance/cases/required_field_proto3.pb.go @@ -0,0 +1,615 @@ +// 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.31.0 +// protoc (unknown) +// source: buf/validate/conformance/cases/required_field_proto3.proto + +package cases + +import ( + _ "github.com/bufbuild/protovalidate/tools/internal/gen/buf/validate" + 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) +) + +type RequiredProto3Scalar struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Val string `protobuf:"bytes,1,opt,name=val,proto3" json:"val,omitempty"` +} + +func (x *RequiredProto3Scalar) Reset() { + *x = RequiredProto3Scalar{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto3Scalar) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto3Scalar) ProtoMessage() {} + +func (x *RequiredProto3Scalar) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto3_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 RequiredProto3Scalar.ProtoReflect.Descriptor instead. +func (*RequiredProto3Scalar) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescGZIP(), []int{0} +} + +func (x *RequiredProto3Scalar) GetVal() string { + if x != nil { + return x.Val + } + return "" +} + +type RequiredProto3OptionalScalar struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Val *string `protobuf:"bytes,1,opt,name=val,proto3,oneof" json:"val,omitempty"` +} + +func (x *RequiredProto3OptionalScalar) Reset() { + *x = RequiredProto3OptionalScalar{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto3OptionalScalar) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto3OptionalScalar) ProtoMessage() {} + +func (x *RequiredProto3OptionalScalar) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto3_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 RequiredProto3OptionalScalar.ProtoReflect.Descriptor instead. +func (*RequiredProto3OptionalScalar) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescGZIP(), []int{1} +} + +func (x *RequiredProto3OptionalScalar) GetVal() string { + if x != nil && x.Val != nil { + return *x.Val + } + return "" +} + +type RequiredProto3Message struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Val *RequiredProto3Message_Msg `protobuf:"bytes,1,opt,name=val,proto3" json:"val,omitempty"` +} + +func (x *RequiredProto3Message) Reset() { + *x = RequiredProto3Message{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto3Message) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto3Message) ProtoMessage() {} + +func (x *RequiredProto3Message) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto3_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 RequiredProto3Message.ProtoReflect.Descriptor instead. +func (*RequiredProto3Message) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescGZIP(), []int{2} +} + +func (x *RequiredProto3Message) GetVal() *RequiredProto3Message_Msg { + if x != nil { + return x.Val + } + return nil +} + +type RequiredProto3OneOf struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Val: + // + // *RequiredProto3OneOf_A + // *RequiredProto3OneOf_B + Val isRequiredProto3OneOf_Val `protobuf_oneof:"val"` +} + +func (x *RequiredProto3OneOf) Reset() { + *x = RequiredProto3OneOf{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto3OneOf) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto3OneOf) ProtoMessage() {} + +func (x *RequiredProto3OneOf) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[3] + 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 RequiredProto3OneOf.ProtoReflect.Descriptor instead. +func (*RequiredProto3OneOf) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescGZIP(), []int{3} +} + +func (m *RequiredProto3OneOf) GetVal() isRequiredProto3OneOf_Val { + if m != nil { + return m.Val + } + return nil +} + +func (x *RequiredProto3OneOf) GetA() string { + if x, ok := x.GetVal().(*RequiredProto3OneOf_A); ok { + return x.A + } + return "" +} + +func (x *RequiredProto3OneOf) GetB() string { + if x, ok := x.GetVal().(*RequiredProto3OneOf_B); ok { + return x.B + } + return "" +} + +type isRequiredProto3OneOf_Val interface { + isRequiredProto3OneOf_Val() +} + +type RequiredProto3OneOf_A struct { + A string `protobuf:"bytes,1,opt,name=a,proto3,oneof"` +} + +type RequiredProto3OneOf_B struct { + B string `protobuf:"bytes,2,opt,name=b,proto3,oneof"` +} + +func (*RequiredProto3OneOf_A) isRequiredProto3OneOf_Val() {} + +func (*RequiredProto3OneOf_B) isRequiredProto3OneOf_Val() {} + +type RequiredProto3Repeated struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Val []string `protobuf:"bytes,1,rep,name=val,proto3" json:"val,omitempty"` +} + +func (x *RequiredProto3Repeated) Reset() { + *x = RequiredProto3Repeated{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto3Repeated) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto3Repeated) ProtoMessage() {} + +func (x *RequiredProto3Repeated) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[4] + 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 RequiredProto3Repeated.ProtoReflect.Descriptor instead. +func (*RequiredProto3Repeated) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescGZIP(), []int{4} +} + +func (x *RequiredProto3Repeated) GetVal() []string { + if x != nil { + return x.Val + } + return nil +} + +type RequiredProto3Map struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Val map[string]string `protobuf:"bytes,1,rep,name=val,proto3" json:"val,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *RequiredProto3Map) Reset() { + *x = RequiredProto3Map{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto3Map) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto3Map) ProtoMessage() {} + +func (x *RequiredProto3Map) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[5] + 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 RequiredProto3Map.ProtoReflect.Descriptor instead. +func (*RequiredProto3Map) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescGZIP(), []int{5} +} + +func (x *RequiredProto3Map) GetVal() map[string]string { + if x != nil { + return x.Val + } + return nil +} + +type RequiredProto3Message_Msg struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Val string `protobuf:"bytes,1,opt,name=val,proto3" json:"val,omitempty"` +} + +func (x *RequiredProto3Message_Msg) Reset() { + *x = RequiredProto3Message_Msg{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequiredProto3Message_Msg) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequiredProto3Message_Msg) ProtoMessage() {} + +func (x *RequiredProto3Message_Msg) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[6] + 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 RequiredProto3Message_Msg.ProtoReflect.Descriptor instead. +func (*RequiredProto3Message_Msg) Descriptor() ([]byte, []int) { + return file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescGZIP(), []int{2, 0} +} + +func (x *RequiredProto3Message_Msg) GetVal() string { + if x != nil { + return x.Val + } + return "" +} + +var File_buf_validate_conformance_cases_required_field_proto3_proto protoreflect.FileDescriptor + +var file_buf_validate_conformance_cases_required_field_proto3_proto_rawDesc = []byte{ + 0x0a, 0x3a, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x63, + 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, + 0x2f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x62, 0x75, + 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x6f, + 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x1a, 0x1b, 0x62, 0x75, + 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x30, 0x0a, 0x14, 0x52, 0x65, 0x71, + 0x75, 0x69, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x53, 0x63, 0x61, 0x6c, 0x61, + 0x72, 0x12, 0x18, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, + 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0x45, 0x0a, 0x1c, 0x52, + 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x63, 0x61, 0x6c, 0x61, 0x72, 0x12, 0x1d, 0x0a, 0x03, 0x76, + 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, + 0x48, 0x00, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x88, 0x01, 0x01, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x76, + 0x61, 0x6c, 0x22, 0x85, 0x01, 0x0a, 0x15, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x53, 0x0a, 0x03, + 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x39, 0x2e, 0x62, 0x75, 0x66, 0x2e, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, + 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x69, + 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x2e, 0x4d, 0x73, 0x67, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x03, 0x76, 0x61, + 0x6c, 0x1a, 0x17, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0x44, 0x0a, 0x13, 0x52, 0x65, + 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4f, 0x6e, 0x65, 0x4f, + 0x66, 0x12, 0x16, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xba, 0x48, + 0x03, 0xc8, 0x01, 0x01, 0x48, 0x00, 0x52, 0x01, 0x61, 0x12, 0x0e, 0x0a, 0x01, 0x62, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x01, 0x62, 0x42, 0x05, 0x0a, 0x03, 0x76, 0x61, 0x6c, + 0x22, 0x32, 0x0a, 0x16, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x33, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x18, 0x0a, 0x03, 0x76, 0x61, + 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, + 0x03, 0x76, 0x61, 0x6c, 0x22, 0xa1, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, + 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x61, 0x70, 0x12, 0x54, 0x0a, 0x03, 0x76, 0x61, + 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, + 0x63, 0x65, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, + 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x61, 0x70, 0x2e, 0x56, 0x61, 0x6c, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x03, 0x76, 0x61, 0x6c, + 0x1a, 0x36, 0x0a, 0x08, 0x56, 0x61, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0xaf, 0x02, 0x0a, 0x22, 0x63, 0x6f, 0x6d, + 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x63, 0x6f, + 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x42, + 0x18, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x33, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x53, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x74, + 0x6f, 0x6f, 0x6c, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, + 0x6e, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x63, + 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, + 0xa2, 0x02, 0x04, 0x42, 0x56, 0x43, 0x43, 0xaa, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x2e, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, + 0x63, 0x65, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0xca, 0x02, 0x1e, 0x42, 0x75, 0x66, 0x5c, 0x56, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, + 0x6e, 0x63, 0x65, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0xe2, 0x02, 0x2a, 0x42, 0x75, 0x66, 0x5c, + 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, + 0x61, 0x6e, 0x63, 0x65, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x21, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, + 0x6e, 0x63, 0x65, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescOnce sync.Once + file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescData = file_buf_validate_conformance_cases_required_field_proto3_proto_rawDesc +) + +func file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescGZIP() []byte { + file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescOnce.Do(func() { + file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescData = protoimpl.X.CompressGZIP(file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescData) + }) + return file_buf_validate_conformance_cases_required_field_proto3_proto_rawDescData +} + +var file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_buf_validate_conformance_cases_required_field_proto3_proto_goTypes = []interface{}{ + (*RequiredProto3Scalar)(nil), // 0: buf.validate.conformance.cases.RequiredProto3Scalar + (*RequiredProto3OptionalScalar)(nil), // 1: buf.validate.conformance.cases.RequiredProto3OptionalScalar + (*RequiredProto3Message)(nil), // 2: buf.validate.conformance.cases.RequiredProto3Message + (*RequiredProto3OneOf)(nil), // 3: buf.validate.conformance.cases.RequiredProto3OneOf + (*RequiredProto3Repeated)(nil), // 4: buf.validate.conformance.cases.RequiredProto3Repeated + (*RequiredProto3Map)(nil), // 5: buf.validate.conformance.cases.RequiredProto3Map + (*RequiredProto3Message_Msg)(nil), // 6: buf.validate.conformance.cases.RequiredProto3Message.Msg + nil, // 7: buf.validate.conformance.cases.RequiredProto3Map.ValEntry +} +var file_buf_validate_conformance_cases_required_field_proto3_proto_depIdxs = []int32{ + 6, // 0: buf.validate.conformance.cases.RequiredProto3Message.val:type_name -> buf.validate.conformance.cases.RequiredProto3Message.Msg + 7, // 1: buf.validate.conformance.cases.RequiredProto3Map.val:type_name -> buf.validate.conformance.cases.RequiredProto3Map.ValEntry + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_buf_validate_conformance_cases_required_field_proto3_proto_init() } +func file_buf_validate_conformance_cases_required_field_proto3_proto_init() { + if File_buf_validate_conformance_cases_required_field_proto3_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto3Scalar); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto3OptionalScalar); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto3Message); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto3OneOf); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto3Repeated); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto3Map); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequiredProto3Message_Msg); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[1].OneofWrappers = []interface{}{} + file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes[3].OneofWrappers = []interface{}{ + (*RequiredProto3OneOf_A)(nil), + (*RequiredProto3OneOf_B)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_buf_validate_conformance_cases_required_field_proto3_proto_rawDesc, + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_buf_validate_conformance_cases_required_field_proto3_proto_goTypes, + DependencyIndexes: file_buf_validate_conformance_cases_required_field_proto3_proto_depIdxs, + MessageInfos: file_buf_validate_conformance_cases_required_field_proto3_proto_msgTypes, + }.Build() + File_buf_validate_conformance_cases_required_field_proto3_proto = out.File + file_buf_validate_conformance_cases_required_field_proto3_proto_rawDesc = nil + file_buf_validate_conformance_cases_required_field_proto3_proto_goTypes = nil + file_buf_validate_conformance_cases_required_field_proto3_proto_depIdxs = nil +} diff --git a/tools/internal/gen/buf/validate/validate.pb.go b/tools/internal/gen/buf/validate/validate.pb.go index 86822750..3e5b7af5 100644 --- a/tools/internal/gen/buf/validate/validate.pb.go +++ b/tools/internal/gen/buf/validate/validate.pb.go @@ -176,26 +176,27 @@ func (x *MessageConstraints) GetCel() []*Constraint { } // The `OneofConstraints` message type enables you to manage constraints for -// oneof fields in your protobuf messages. Use the `required` constraint to ensure -// that exactly one of the fields within a oneof is set; validation will fail -// if none of the fields in the oneof are set: +// oneof fields in your protobuf messages. type OneofConstraints struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // `required` is an optional boolean attribute that ensures that - // exactly one of the field options in a oneof is set; validation fails if - // no fields in the oneof are set. + // If `required` is true, exactly one field of the oneof must be present. A + // validation error is returned if no fields in the oneof are present. The + // field itself may still be a default value; further constraints + // should be placed on the fields themselves to ensure they are valid values, + // such as `min_len` or `gt`. // // ```proto // // message MyMessage { // oneof value { - // // The field `a` or `b` must be set. + // // Either `a` or `b` must be set. If `a` is set, it must also be + // // non-empty; whereas if `b` is set, it can still be an empty string. // option (buf.validate.oneof).required = true; - // optional string a = 1; - // optional string b = 2; + // string a = 1 [(buf.validate.field).string.min_len = 1]; + // string b = 2; // } // } // @@ -279,31 +280,41 @@ type FieldConstraints struct { // // ``` Skipped bool `protobuf:"varint,24,opt,name=skipped,proto3" json:"skipped,omitempty"` - // `required` is an optional boolean attribute that specifies that - // this field must be set. If required is set to true, the field value must - // not be empty; otherwise, an error message will be generated. + // If `required` is true, the field must be populated. Field presence can be + // described as "serialized in the wire format," which follows the following rules: // - // Note that `required` validates that `repeated` fields are non-empty, that is - // setting a `repeated` field as `required` is equivalent to `repeated.min_items = 1`. + // - the following "nullable" fields must be explicitly set to be considered present: + // - singular message fields (may be their empty value) + // - member fields of a oneof (may be their default value) + // - proto3 optional fields (may be their default value) + // - proto2 scalar fields + // + // - proto3 scalar fields must be non-zero to be considered present + // - repeated and map fields must be non-empty to be considered present // // ```proto // // message MyMessage { - // // The field `value` must be set. + // // The field `value` must be set to a non-null value. // optional MyOtherMessage value = 1 [(buf.validate.field).required = true]; // } // // ``` Required bool `protobuf:"varint,25,opt,name=required,proto3" json:"required,omitempty"` - // `ignore_empty` specifies that the validation rules of this field should be - // evaluated only if the field isn't empty. If the field is empty, no validation - // rules are applied. + // If `ignore_empty` is true and applied to a non-nullable field (see + // `required` for more details), validation is skipped on the field if it is + // the default or empty value. Adding `ignore_empty` to a "nullable" field is + // a noop as these unset fields already skip validation (with the exception + // of `required`). // // ```proto // // message MyRepeated { - // // The field `value` validation rules should be evaluated only if the field isn't empty. - // repeated string value = 1 [(buf.validate.field).ignore_empty = true]; + // // The field `value` min_len rule is only applied if the field isn't empty. + // repeated string value = 1 [ + // (buf.validate.field).ignore_empty = true, + // (buf.validate.field).min_len = 5 + // ]; // } // // ``` diff --git a/tools/protovalidate-conformance/internal/cases/cases.go b/tools/protovalidate-conformance/internal/cases/cases.go index cb2b20e3..aa12a321 100644 --- a/tools/protovalidate-conformance/internal/cases/cases.go +++ b/tools/protovalidate-conformance/internal/cases/cases.go @@ -39,6 +39,7 @@ func GlobalSuites() suites.Suites { "standard_constraints/nested": nestedSuite(), "standard_constraints/oneof": oneofSuite(), "standard_constraints/repeated": repeatedSuite(), + "standard_constraints/required": requiredSuite(), "standard_constraints/sfixed32": sfixed32Suite(), "standard_constraints/sfixed64": sfixed64Suite(), "standard_constraints/sint32": sint32Suite(), diff --git a/tools/protovalidate-conformance/internal/cases/cases_oneof.go b/tools/protovalidate-conformance/internal/cases/cases_oneof.go index 92ca240d..ed64a063 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_oneof.go +++ b/tools/protovalidate-conformance/internal/cases/cases_oneof.go @@ -59,14 +59,42 @@ func oneofSuite() suites.Suite { Message: &cases.Oneof{O: &cases.Oneof_Z{Z: &cases.TestOneofMsg{}}}, Expected: results.Violations(&validate.Violation{FieldPath: "z.val", ConstraintId: "bool.const"}), }, - "required/valid": { + "required/valid/empty": { Message: &cases.OneofRequired{O: &cases.OneofRequired_X{X: ""}}, Expected: results.Success(true), }, + "required/valid/non-empty": { + Message: &cases.OneofRequired{O: &cases.OneofRequired_X{X: "foo"}}, + Expected: results.Success(true), + }, "required/invalid": { Message: &cases.OneofRequired{}, Expected: results.Violations(&validate.Violation{FieldPath: "o", ConstraintId: "required"}), }, + "required/required_field/valid/empty": { + Message: &cases.OneofRequiredWithRequiredField{ + O: &cases.OneofRequiredWithRequiredField_A{A: ""}, + }, + Expected: results.Success(true), + }, + "required/required_field/valid/non-empty": { + Message: &cases.OneofRequiredWithRequiredField{ + O: &cases.OneofRequiredWithRequiredField_A{A: "foo"}, + }, + Expected: results.Success(true), + }, + "required/required_field/wrong_field": { + Message: &cases.OneofRequiredWithRequiredField{ + O: &cases.OneofRequiredWithRequiredField_B{B: "foo"}, + }, + Expected: results.Violations(&validate.Violation{FieldPath: "a", ConstraintId: "required"}), + }, + "required/required_field/invalid": { + Message: &cases.OneofRequiredWithRequiredField{}, + Expected: results.Violations( + &validate.Violation{FieldPath: "o", ConstraintId: "required"}, + &validate.Violation{FieldPath: "a", ConstraintId: "required"}), + }, "ignore_empty/X/valid": { Message: &cases.OneofIgnoreEmpty{O: &cases.OneofIgnoreEmpty_X{X: ""}}, Expected: results.Success(true), diff --git a/tools/protovalidate-conformance/internal/cases/cases_required.go b/tools/protovalidate-conformance/internal/cases/cases_required.go new file mode 100644 index 00000000..dfa53913 --- /dev/null +++ b/tools/protovalidate-conformance/internal/cases/cases_required.go @@ -0,0 +1,172 @@ +// 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. + +package cases + +import ( + "github.com/bufbuild/protovalidate/tools/internal/gen/buf/validate" + "github.com/bufbuild/protovalidate/tools/internal/gen/buf/validate/conformance/cases" + "github.com/bufbuild/protovalidate/tools/protovalidate-conformance/internal/results" + "github.com/bufbuild/protovalidate/tools/protovalidate-conformance/internal/suites" + "google.golang.org/protobuf/proto" +) + +func requiredSuite() suites.Suite { + return suites.Suite{ + "proto2/scalar/optional/nonzero": suites.Case{ + Message: &cases.RequiredProto2ScalarOptional{Val: proto.String("foo")}, + Expected: results.Success(true), + }, + "proto2/scalar/optional/zero": suites.Case{ + Message: &cases.RequiredProto2ScalarOptional{Val: proto.String("")}, + Expected: results.Success(true), + }, + "proto2/scalar/optional/unset": suites.Case{ + Message: &cases.RequiredProto2ScalarOptional{}, + Expected: results.Violations(&validate.Violation{FieldPath: "val", ConstraintId: "required"}), + }, + "proto2/scalar/optional_with_default/nonzero": suites.Case{ + Message: &cases.RequiredProto2ScalarOptionalDefault{Val: proto.String("bar")}, + Expected: results.Success(true), + }, + "proto2/scalar/optional_with_default/zero": suites.Case{ + Message: &cases.RequiredProto2ScalarOptionalDefault{Val: proto.String("")}, + Expected: results.Success(true), + }, + "proto2/scalar/optional_with_default/default": suites.Case{ + Message: &cases.RequiredProto2ScalarOptionalDefault{Val: proto.String("foo")}, + Expected: results.Success(true), + }, + "proto2/scalar/optional_with_default/unset": suites.Case{ + Message: &cases.RequiredProto2ScalarOptionalDefault{}, + Expected: results.Violations(&validate.Violation{FieldPath: "val", ConstraintId: "required"}), + }, + "proto2/scalar/required/nonzero": suites.Case{ + Message: &cases.RequiredProto2ScalarRequired{Val: proto.String("foo")}, + Expected: results.Success(true), + }, + "proto2/scalar/required/zero": suites.Case{ + Message: &cases.RequiredProto2ScalarRequired{Val: proto.String("")}, + Expected: results.Success(true), + }, + "proto2/message/nonzero": suites.Case{ + Message: &cases.RequiredProto2Message{Val: &cases.RequiredProto2Message_Msg{Val: proto.String("foo")}}, + Expected: results.Success(true), + }, + "proto2/message/zero": suites.Case{ + Message: &cases.RequiredProto2Message{Val: &cases.RequiredProto2Message_Msg{}}, + Expected: results.Success(true), + }, + "proto2/message/unset": suites.Case{ + Message: &cases.RequiredProto2Message{}, + Expected: results.Violations(&validate.Violation{FieldPath: "val", ConstraintId: "required"}), + }, + "proto2/oneof/nonzero": suites.Case{ + Message: &cases.RequiredProto2Oneof{Val: &cases.RequiredProto2Oneof_A{A: "foo"}}, + Expected: results.Success(true), + }, + "proto2/oneof/zero": suites.Case{ + Message: &cases.RequiredProto2Oneof{Val: &cases.RequiredProto2Oneof_A{A: ""}}, + Expected: results.Success(true), + }, + "proto2/oneof/other_member": suites.Case{ + Message: &cases.RequiredProto2Oneof{Val: &cases.RequiredProto2Oneof_B{B: "foo"}}, + Expected: results.Violations(&validate.Violation{FieldPath: "a", ConstraintId: "required"}), + }, + "proto2/oneof/unset": suites.Case{ + Message: &cases.RequiredProto2Oneof{}, + Expected: results.Violations(&validate.Violation{FieldPath: "a", ConstraintId: "required"}), + }, + "proto2/repeated/nonempty": suites.Case{ + Message: &cases.RequiredProto2Repeated{Val: []string{"foo"}}, + Expected: results.Success(true), + }, + "proto2/repeated/empty": suites.Case{ + Message: &cases.RequiredProto2Repeated{}, + Expected: results.Violations(&validate.Violation{FieldPath: "val", ConstraintId: "required"}), + }, + "proto2/map/nonempty": suites.Case{ + Message: &cases.RequiredProto2Map{Val: map[string]string{"foo": "bar"}}, + Expected: results.Success(true), + }, + "proto2/map/empty": suites.Case{ + Message: &cases.RequiredProto2Map{}, + Expected: results.Violations(&validate.Violation{FieldPath: "val", ConstraintId: "required"}), + }, + "proto3/scalar/nonzero": suites.Case{ + Message: &cases.RequiredProto3Scalar{Val: "foo"}, + Expected: results.Success(true), + }, + "proto3/scalar/zero": suites.Case{ + Message: &cases.RequiredProto3Scalar{Val: ""}, + Expected: results.Violations(&validate.Violation{FieldPath: "val", ConstraintId: "required"}), + }, + "proto3/scalar/optional/nonzero": suites.Case{ + Message: &cases.RequiredProto3OptionalScalar{Val: proto.String("foo")}, + Expected: results.Success(true), + }, + "proto3/scalar/optional/zero": suites.Case{ + Message: &cases.RequiredProto3OptionalScalar{Val: proto.String("")}, + Expected: results.Success(true), + }, + "proto3/scalar/optional/unset": suites.Case{ + Message: &cases.RequiredProto3OptionalScalar{}, + Expected: results.Violations(&validate.Violation{FieldPath: "val", ConstraintId: "required"}), + }, + "proto3/message/nonzero": suites.Case{ + Message: &cases.RequiredProto3Message{Val: &cases.RequiredProto3Message_Msg{Val: "foo"}}, + Expected: results.Success(true), + }, + "proto3/message/zero": suites.Case{ + Message: &cases.RequiredProto3Message{Val: &cases.RequiredProto3Message_Msg{}}, + Expected: results.Success(true), + }, + "proto3/message/unset": suites.Case{ + Message: &cases.RequiredProto3Message{}, + Expected: results.Violations(&validate.Violation{FieldPath: "val", ConstraintId: "required"}), + }, + "proto3/oneof/nonzero": suites.Case{ + Message: &cases.RequiredProto3OneOf{Val: &cases.RequiredProto3OneOf_A{A: "foo"}}, + Expected: results.Success(true), + }, + "proto3/oneof/zero": suites.Case{ + Message: &cases.RequiredProto3OneOf{Val: &cases.RequiredProto3OneOf_A{A: ""}}, + Expected: results.Success(true), + }, + "proto3/oneof/other_member": suites.Case{ + Message: &cases.RequiredProto3OneOf{Val: &cases.RequiredProto3OneOf_B{B: "foo"}}, + Expected: results.Violations(&validate.Violation{FieldPath: "a", ConstraintId: "required"}), + }, + "proto3/oneof/unset": suites.Case{ + Message: &cases.RequiredProto3OneOf{}, + Expected: results.Violations(&validate.Violation{FieldPath: "a", ConstraintId: "required"}), + }, + "proto3/repeated/nonempty": suites.Case{ + Message: &cases.RequiredProto3Repeated{Val: []string{"foo"}}, + Expected: results.Success(true), + }, + "proto3/repeated/empty": suites.Case{ + Message: &cases.RequiredProto3Repeated{}, + Expected: results.Violations(&validate.Violation{FieldPath: "val", ConstraintId: "required"}), + }, + "proto3/map/nonempty": suites.Case{ + Message: &cases.RequiredProto3Map{Val: map[string]string{"foo": "bar"}}, + Expected: results.Success(true), + }, + "proto3/map/empty": suites.Case{ + Message: &cases.RequiredProto3Map{}, + Expected: results.Violations(&validate.Violation{FieldPath: "val", ConstraintId: "required"}), + }, + } +}