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 tests for IGNORE_ALWAYS #322

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -59,6 +59,21 @@ message Proto2ScalarOptionalIgnoreDefaultWithDefault {
];
}

message Proto2ScalarOptionalIgnoreAlways {
optional int32 val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).int32.gt = 0
];
}

message Proto2ScalarOptionalIgnoreAlwaysWithDefault {
optional int32 val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).int32.gt = 0,
default = -42
];
}

message Proto2ScalarRequiredIgnoreUnspecified {
required int32 val = 1 [(buf.validate.field).int32.gt = 0];
}
Expand Down Expand Up @@ -100,6 +115,21 @@ message Proto2ScalarRequiredIgnoreDefaultWithDefault {
];
}

message Proto2ScalarRequiredIgnoreAlways {
required int32 val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).int32.gt = 0
];
}

message Proto2ScalarRequiredIgnoreAlwaysWithDefault {
required int32 val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).int32.gt = 0,
default = -42
];
}

message Proto2MessageOptionalIgnoreUnspecified {
optional Msg val = 1 [(buf.validate.field).cel = {
id: "proto2.message.ignore.empty"
Expand Down Expand Up @@ -139,6 +169,20 @@ message Proto2MessageOptionalIgnoreDefault {
}
}

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

message Proto2MessageRequiredIgnoreUnspecified {
required Msg val = 1 [(buf.validate.field).cel = {
id: "proto2.message.ignore.empty"
Expand Down Expand Up @@ -178,6 +222,20 @@ message Proto2MessageRequiredIgnoreDefault {
}
}

message Proto2MessageRequiredIgnoreAlways {
required Msg val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).cel = {
id: "proto2.message.ignore.always"
message: "foobar"
expression: "this.val == 'foo'"
}
];
message Msg {
optional string val = 1;
}
}

message Proto2OneofIgnoreUnspecified {
oneof o {
int32 val = 1 [(buf.validate.field).int32.gt = 0];
Expand Down Expand Up @@ -231,6 +289,25 @@ message Proto2OneofIgnoreDefaultWithDefault {
}
}

message Proto2OneofIgnoreAlways {
oneof o {
int32 val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).int32.gt = 0
];
}
}

message Proto2OneofIgnoreAlwaysWithDefault {
oneof o {
int32 val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).int32.gt = 0,
default = -42
];
}
}

message Proto2RepeatedIgnoreUnspecified {
repeated int32 val = 1 [(buf.validate.field).repeated.min_items = 3];
}
Expand All @@ -249,6 +326,13 @@ message Proto2RepeatedIgnoreDefault {
];
}

message Proto2RepeatedIgnoreAlways {
repeated int32 val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).repeated.min_items = 3
];
}

message Proto2MapIgnoreUnspecified {
map<int32, int32> val = 1 [(buf.validate.field).map.min_pairs = 3];
}
Expand All @@ -267,6 +351,13 @@ message Proto2MapIgnoreDefault {
];
}

message Proto2MapIgnoreAlways {
map<int32, int32> val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).map.min_pairs = 3
];
}

message Proto2RepeatedItemIgnoreUnspecified {
repeated int32 val = 1 [(buf.validate.field).repeated.items.int32.gt = 0];
}
Expand All @@ -285,6 +376,13 @@ message Proto2RepeatedItemIgnoreDefault {
];
}

message Proto2RepeatedItemIgnoreAlways {
repeated int32 val = 1 [
(buf.validate.field).repeated.items.ignore = IGNORE_ALWAYS,
(buf.validate.field).repeated.items.int32.gt = 0
];
}

message Proto2MapKeyIgnoreUnspecified {
map<int32, int32> val = 1 [(buf.validate.field).map.keys.int32.gt = 0];
}
Expand All @@ -303,6 +401,13 @@ message Proto2MapKeyIgnoreDefault {
];
}

message Proto2MapKeyIgnoreAlways {
map<int32, int32> val = 1 [
(buf.validate.field).map.keys.ignore = IGNORE_ALWAYS,
(buf.validate.field).map.keys.int32.gt = 0
];
}

message Proto2MapValueIgnoreUnspecified {
map<int32, int32> val = 1 [(buf.validate.field).map.values.int32.gt = 0];
}
Expand All @@ -320,3 +425,10 @@ message Proto2MapValueIgnoreDefault {
(buf.validate.field).map.values.int32.gt = 0
];
}

message Proto2MapValueIgnoreAlways {
map<int32, int32> val = 1 [
(buf.validate.field).map.values.ignore = IGNORE_ALWAYS,
(buf.validate.field).map.values.int32.gt = 0
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ message Proto3ScalarOptionalIgnoreDefault {
];
}

message Proto3ScalarOptionalIgnoreAlways {
optional int32 val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).int32.gt = 0
];
}

message Proto3ScalarIgnoreUnspecified {
int32 val = 1 [(buf.validate.field).int32.gt = 0];
}
Expand All @@ -54,6 +61,13 @@ message Proto3ScalarIgnoreDefault {
];
}

message Proto3ScalarIgnoreAlways {
int32 val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).int32.gt = 0
];
}

message Proto3MessageOptionalIgnoreUnspecified {
optional Msg val = 1 [(buf.validate.field).cel = {
id: "proto3.message.ignore.empty"
Expand Down Expand Up @@ -93,6 +107,20 @@ message Proto3MessageOptionalIgnoreDefault {
}
}

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

message Proto3MessageIgnoreUnspecified {
Msg val = 1 [(buf.validate.field).cel = {
id: "proto3.message.ignore.empty"
Expand Down Expand Up @@ -132,6 +160,20 @@ message Proto3MessageIgnoreDefault {
}
}

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

message Proto3OneofIgnoreUnspecified {
oneof o {
int32 val = 1 [(buf.validate.field).int32.gt = 0];
Expand All @@ -156,6 +198,15 @@ message Proto3OneofIgnoreDefault {
}
}

message Proto3OneofIgnoreAlways {
oneof o {
int32 val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).int32.gt = 0
];
}
}

message Proto3RepeatedIgnoreUnspecified {
repeated int32 val = 1 [(buf.validate.field).repeated.min_items = 3];
}
Expand All @@ -174,6 +225,13 @@ message Proto3RepeatedIgnoreDefault {
];
}

message Proto3RepeatedIgnoreAlways {
repeated int32 val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).repeated.min_items = 3
];
}

message Proto3MapIgnoreUnspecified {
map<int32, int32> val = 1 [(buf.validate.field).map.min_pairs = 3];
}
Expand All @@ -192,6 +250,13 @@ message Proto3MapIgnoreDefault {
];
}

message Proto3MapIgnoreAlways {
map<int32, int32> val = 1 [
(buf.validate.field).ignore = IGNORE_ALWAYS,
(buf.validate.field).map.min_pairs = 3
];
}

message Proto3RepeatedItemIgnoreUnspecified {
repeated int32 val = 1 [(buf.validate.field).repeated.items.int32.gt = 0];
}
Expand All @@ -210,6 +275,13 @@ message Proto3RepeatedItemIgnoreDefault {
];
}

message Proto3RepeatedItemIgnoreAlways {
repeated int32 val = 1 [
(buf.validate.field).repeated.items.ignore = IGNORE_ALWAYS,
(buf.validate.field).repeated.items.int32.gt = 0
];
}

message Proto3MapKeyIgnoreUnspecified {
map<int32, int32> val = 1 [(buf.validate.field).map.keys.int32.gt = 0];
}
Expand All @@ -228,6 +300,13 @@ message Proto3MapKeyIgnoreDefault {
];
}

message Proto3MapKeyIgnoreAlways {
map<int32, int32> val = 1 [
(buf.validate.field).map.keys.ignore = IGNORE_ALWAYS,
(buf.validate.field).map.keys.int32.gt = 0
];
}

message Proto3MapValueIgnoreUnspecified {
map<int32, int32> val = 1 [(buf.validate.field).map.values.int32.gt = 0];
}
Expand All @@ -245,3 +324,10 @@ message Proto3MapValueIgnoreDefault {
(buf.validate.field).map.values.int32.gt = 0
];
}

message Proto3MapValueIgnoreAlways {
map<int32, int32> val = 1 [
(buf.validate.field).map.values.ignore = IGNORE_ALWAYS,
(buf.validate.field).map.values.int32.gt = 0
];
}
Loading