|
| 1 | +// Copyright 2023 Buf Technologies, Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +edition = "2023"; |
| 16 | + |
| 17 | +package buf.validate.conformance.cases; |
| 18 | + |
| 19 | +import "buf/validate/validate.proto"; |
| 20 | + |
| 21 | +message IgnoreEmptyEditionsScalarExplicitPresence { |
| 22 | + int32 val = 1 [ |
| 23 | + (buf.validate.field).ignore_empty = true, |
| 24 | + (buf.validate.field).int32.gt = 0 |
| 25 | + ]; |
| 26 | +} |
| 27 | + |
| 28 | +message IgnoreEmptyEditionsScalarExplicitPresenceWithDefault { |
| 29 | + int32 val = 1 [ |
| 30 | + (buf.validate.field).ignore_empty = true, |
| 31 | + (buf.validate.field).int32.gt = 0, |
| 32 | + default = 42 |
| 33 | + ]; |
| 34 | +} |
| 35 | + |
| 36 | +message IgnoreEmptyEditionsScalarImplicitPresence { |
| 37 | + int32 val = 1 [ |
| 38 | + features.field_presence = IMPLICIT, |
| 39 | + (buf.validate.field).ignore_empty = true, |
| 40 | + (buf.validate.field).int32.gt = 0 |
| 41 | + ]; |
| 42 | +} |
| 43 | + |
| 44 | +message IgnoreEmptyEditionsScalarLegacyRequired { |
| 45 | + int32 val = 1 [ |
| 46 | + features.field_presence = LEGACY_REQUIRED, |
| 47 | + (buf.validate.field).ignore_empty = true, |
| 48 | + (buf.validate.field).int32.gt = 0 |
| 49 | + ]; |
| 50 | +} |
| 51 | + |
| 52 | +message IgnoreEmptyEditionsScalarLegacyRequiredWithDefault { |
| 53 | + int32 val = 1 [ |
| 54 | + features.field_presence = LEGACY_REQUIRED, |
| 55 | + (buf.validate.field).ignore_empty = true, |
| 56 | + (buf.validate.field).int32.gt = 0, |
| 57 | + default = 42 |
| 58 | + ]; |
| 59 | +} |
| 60 | + |
| 61 | +message IgnoreEmptyEditionsMessageExplicitPresence { |
| 62 | + Msg val = 1 [ |
| 63 | + (buf.validate.field).ignore_empty = true, |
| 64 | + (buf.validate.field).cel = { |
| 65 | + id: "ignore_empty.editions.message" |
| 66 | + message: "foobar" |
| 67 | + expression: "this.val == 'foo'" |
| 68 | + } |
| 69 | + ]; |
| 70 | + message Msg { |
| 71 | + string val = 1; |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +message IgnoreEmptyEditionsMessageExplicitPresenceDelimited { |
| 76 | + Msg val = 1 [ |
| 77 | + features.message_encoding = DELIMITED, |
| 78 | + (buf.validate.field).ignore_empty = true, |
| 79 | + (buf.validate.field).cel = { |
| 80 | + id: "ignore_empty.editions.message" |
| 81 | + message: "foobar" |
| 82 | + expression: "this.val == 'foo'" |
| 83 | + } |
| 84 | + ]; |
| 85 | + message Msg { |
| 86 | + string val = 1; |
| 87 | + } |
| 88 | +} |
| 89 | + |
| 90 | +message IgnoreEmptyEditionsMessageLegacyRequired { |
| 91 | + Msg val = 1 [ |
| 92 | + features.field_presence = LEGACY_REQUIRED, |
| 93 | + (buf.validate.field).ignore_empty = true, |
| 94 | + (buf.validate.field).cel = { |
| 95 | + id: "ignore_empty.editions.message" |
| 96 | + message: "foobar" |
| 97 | + expression: "this.val == 'foo'" |
| 98 | + } |
| 99 | + ]; |
| 100 | + message Msg { |
| 101 | + string val = 1; |
| 102 | + } |
| 103 | +} |
| 104 | + |
| 105 | +message IgnoreEmptyEditionsMessageLegacyRequiredDelimited { |
| 106 | + Msg val = 1 [ |
| 107 | + features.message_encoding = DELIMITED, |
| 108 | + features.field_presence = LEGACY_REQUIRED, |
| 109 | + (buf.validate.field).ignore_empty = true, |
| 110 | + (buf.validate.field).cel = { |
| 111 | + id: "ignore_empty.editions.message" |
| 112 | + message: "foobar" |
| 113 | + expression: "this.val == 'foo'" |
| 114 | + } |
| 115 | + ]; |
| 116 | + message Msg { |
| 117 | + string val = 1; |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +message IgnoreEmptyEditionsOneof { |
| 122 | + oneof o { |
| 123 | + int32 val = 1 [ |
| 124 | + (buf.validate.field).ignore_empty = true, |
| 125 | + (buf.validate.field).int32.gt = 0 |
| 126 | + ]; |
| 127 | + } |
| 128 | +} |
| 129 | + |
| 130 | +message IgnoreEmptyEditionsRepeated { |
| 131 | + repeated int32 val = 1 [ |
| 132 | + (buf.validate.field).ignore_empty = true, |
| 133 | + (buf.validate.field).repeated.min_items = 3 |
| 134 | + ]; |
| 135 | +} |
| 136 | + |
| 137 | +message IgnoreEmptyEditionsRepeatedExpanded { |
| 138 | + repeated int32 val = 1 [ |
| 139 | + features.repeated_field_encoding = EXPANDED, |
| 140 | + (buf.validate.field).ignore_empty = true, |
| 141 | + (buf.validate.field).repeated.min_items = 3 |
| 142 | + ]; |
| 143 | +} |
| 144 | + |
| 145 | +message IgnoreEmptyEditionsMap { |
| 146 | + map<int32, int32> val = 1 [ |
| 147 | + (buf.validate.field).ignore_empty = true, |
| 148 | + (buf.validate.field).map.min_pairs = 3 |
| 149 | + ]; |
| 150 | +} |
0 commit comments