Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conformance tests for ignore_empty #126

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ proto_library(
"bytes.proto",
"enums.proto",
"filename-with-dash.proto",
"ignore_empty_proto2.proto",
"ignore_empty_proto3.proto",
"kitchen_sink.proto",
"maps.proto",
"messages.proto",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// 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 IgnoreEmptyProto2ScalarOptional {
optional int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).int32.gt = 0
];
}

message IgnoreEmptyProto2ScalarOptionalWithDefault {
optional int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).int32.gt = 0,
default = 42
];
}

message IgnoreEmptyProto2ScalarRequired {
required int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).int32.gt = 0
];
}

message IgnoreEmptyProto2Message {
optional Msg val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).cel = {
id: "ignore_empty.proto2.message",
message: "foobar",
expression: "this.val == 'foo'",
}
];
message Msg {
optional string val = 1;
}
}

message IgnoreEmptyProto2Oneof {
oneof o {
int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).int32.gt = 0
];
}
}

message IgnoreEmptyProto2Repeated {
repeated int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).repeated.min_items = 3
];
}

message IgnoreEmptyProto2Map {
map<int32, int32> val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).map.min_pairs = 3
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// 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 IgnoreEmptyProto3Scalar {
int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).int32.gt = 0
];
}

message IgnoreEmptyProto3OptionalScalar {
optional int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).int32.gt = 0
];
}

message IgnoreEmptyProto3Message {
optional Msg val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).cel = {
id: "ignore_empty.proto3.message",
message: "foobar",
expression: "this.val == 'foo'",
}
];
message Msg {
string val = 1;
}
}

message IgnoreEmptyProto3Oneof {
oneof o {
int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).int32.gt = 0
];
}
}

message IgnoreEmptyProto3Repeated {
repeated int32 val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).repeated.min_items = 3
];
}

message IgnoreEmptyProto3Map {
map<int32, int32> val = 1 [
(buf.validate.field).ignore_empty = true,
(buf.validate.field).map.min_pairs = 3
];
}
Loading