-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add conformance tests for ignore_empty
- Loading branch information
Showing
7 changed files
with
1,818 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
proto/protovalidate-testing/buf/validate/conformance/cases/ignore_empty_proto2.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// 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"; | ||
|
||
// all fields in this message should not be impacted by ignore_empty | ||
message IgnoreEmptyProto2Noop { | ||
optional Msg msg = 1 [ | ||
(buf.validate.field).ignore_empty = true, | ||
(buf.validate.field).cel = { | ||
id: "ignore_empty.proto2.message", | ||
message: "val must be foo", | ||
expression: "this.val == 'foo'", | ||
} | ||
]; | ||
oneof o { | ||
int32 a = 2 [ | ||
(buf.validate.field).ignore_empty = true, | ||
(buf.validate.field).int32.gt = 0 | ||
]; | ||
} | ||
optional string str = 3 [ | ||
(buf.validate.field).ignore_empty = true, | ||
(buf.validate.field).string.min_len = 5 | ||
]; | ||
message Msg { | ||
optional string val = 1; | ||
} | ||
} | ||
|
||
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 | ||
]; | ||
} |
70 changes: 70 additions & 0 deletions
70
proto/protovalidate-testing/buf/validate/conformance/cases/ignore_empty_proto3.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
]; | ||
} |
Oops, something went wrong.