diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/021ad16ef72d5244906bf3b69de9a4eed623a50661406eee9c847f5f2d4fbcacba91c3895d8d84e4836776a9fd93b250cad5d9c908dcce5e1e29bf91d56cc21f b/modules/sync/bufbuild/protovalidate-testing/cas/021ad16ef72d5244906bf3b69de9a4eed623a50661406eee9c847f5f2d4fbcacba91c3895d8d84e4836776a9fd93b250cad5d9c908dcce5e1e29bf91d56cc21f new file mode 100644 index 00000000..70da7c75 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/021ad16ef72d5244906bf3b69de9a4eed623a50661406eee9c847f5f2d4fbcacba91c3895d8d84e4836776a9fd93b250cad5d9c908dcce5e1e29bf91d56cc21f @@ -0,0 +1,114 @@ +// Copyright 2023-2026 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 BytesNone { + bytes val = 1; +} +message BytesConst { + bytes val = 1 [(buf.validate.field).bytes.const = "foo"]; +} +message BytesIn { + bytes val = 1 [(buf.validate.field).bytes = { + in: [ + "bar", + "baz" + ] + }]; +} +message BytesNotIn { + bytes val = 1 [(buf.validate.field).bytes = { + not_in: [ + "fizz", + "buzz" + ] + }]; +} +message BytesLen { + bytes val = 1 [(buf.validate.field).bytes.len = 3]; +} +message BytesMinLen { + bytes val = 1 [(buf.validate.field).bytes.min_len = 3]; +} +message BytesMaxLen { + bytes val = 1 [(buf.validate.field).bytes.max_len = 5]; +} +message BytesMinMaxLen { + bytes val = 1 [(buf.validate.field).bytes = { + min_len: 3 + max_len: 5 + }]; +} +message BytesEqualMinMaxLen { + bytes val = 1 [(buf.validate.field).bytes = { + min_len: 5 + max_len: 5 + }]; +} +message BytesPattern { + bytes val = 1 [(buf.validate.field).bytes.pattern = "^[\\x00-\\x7F]+$"]; +} +message BytesPrefix { + bytes val = 1 [(buf.validate.field).bytes.prefix = "\x99"]; +} +message BytesContains { + bytes val = 1 [(buf.validate.field).bytes.contains = "bar"]; +} +message BytesSuffix { + bytes val = 1 [(buf.validate.field).bytes.suffix = "buz\x7a"]; +} +message BytesIP { + bytes val = 1 [(buf.validate.field).bytes.ip = true]; +} +message BytesNotIP { + bytes val = 1 [(buf.validate.field).bytes.ip = false]; +} +message BytesIPv4 { + bytes val = 1 [(buf.validate.field).bytes.ipv4 = true]; +} +message BytesNotIPv4 { + bytes val = 1 [(buf.validate.field).bytes.ipv4 = false]; +} +message BytesIPv6 { + bytes val = 1 [(buf.validate.field).bytes.ipv6 = true]; +} +message BytesNotIPv6 { + bytes val = 1 [(buf.validate.field).bytes.ipv6 = false]; +} +message BytesIPv6Ignore { + bytes val = 1 [ + (buf.validate.field).bytes.ipv6 = true, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} +message BytesUUID { + bytes val = 1 [(buf.validate.field).bytes.uuid = true]; +} +message BytesNotUUID { + bytes val = 1 [(buf.validate.field).bytes.uuid = false]; +} +message BytesUUIDIgnore { + bytes val = 1 [ + (buf.validate.field).bytes.uuid = true, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} +message BytesExample { + bytes val = 1 [(buf.validate.field).bytes.example = "\x99"]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/0778d32a5e2a64156a45907acccb3c6ce84da912034f15425ad30136b44f67f6a900f9e28fea0ea112813526b9b3bf1f8e89fdc1be8352d4d7e888f1980b78b6 b/modules/sync/bufbuild/protovalidate-testing/cas/0778d32a5e2a64156a45907acccb3c6ce84da912034f15425ad30136b44f67f6a900f9e28fea0ea112813526b9b3bf1f8e89fdc1be8352d4d7e888f1980b78b6 new file mode 100644 index 00000000..b32d2a92 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/0778d32a5e2a64156a45907acccb3c6ce84da912034f15425ad30136b44f67f6a900f9e28fea0ea112813526b9b3bf1f8e89fdc1be8352d4d7e888f1980b78b6 @@ -0,0 +1,125 @@ +// Copyright 2023-2026 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 RequiredProto3ScalarIgnoreAlways { + string val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} + +message RequiredProto3OptionalScalar { + optional string val = 1 [(buf.validate.field).required = true]; +} +message RequiredProto3OptionalScalarIgnoreAlways { + optional string val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} + +message RequiredProto3Message { + Msg val = 1 [(buf.validate.field).required = true]; + message Msg { + string val = 1; + } +} +message RequiredProto3MessageIgnoreAlways { + Msg val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; + message Msg { + string val = 1; + } +} + +message RequiredProto3OneOf { + oneof val { + string a = 1 [(buf.validate.field).required = true]; + string b = 2; + } +} +message RequiredProto3OneOfIgnoreAlways { + oneof val { + string a = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; + string b = 2; + } +} + +message RequiredProto3Repeated { + repeated string val = 1 [(buf.validate.field).required = true]; +} +message RequiredProto3RepeatedIgnoreAlways { + repeated string val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} + +message RequiredProto3Map { + map val = 1 [(buf.validate.field).required = true]; +} +message RequiredProto3MapIgnoreAlways { + map val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} + +message RequiredProto3MapKey { + map val = 1 [(buf.validate.field).map.keys.required = true]; +} + +message RequiredProto3MapValue { + map val = 1 [(buf.validate.field).map.values.required = true]; +} + +message RequiredProto3RepeatedItem { + repeated string val = 1 [(buf.validate.field).repeated.items.required = true]; +} + +message RequiredImplicitProto3Scalar { + string val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string.min_len = 1, + (buf.validate.field).string.max_len = 2 + ]; +} +message RequiredImplicitProto3Repeated { + repeated string val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).repeated.min_items = 1, + (buf.validate.field).repeated.max_items = 2 + ]; +} +message RequiredImplicitProto3Map { + map val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).map.min_pairs = 1, + (buf.validate.field).map.max_pairs = 2 + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/119e3be777940bcf8f16f4d087987abfda338f1cdfdbf9faacca1935951d3c30948a794af2b9e26dd8c63e332f0b6c98ef5dcd01952bfe0c8540081b4c53ece6 b/modules/sync/bufbuild/protovalidate-testing/cas/119e3be777940bcf8f16f4d087987abfda338f1cdfdbf9faacca1935951d3c30948a794af2b9e26dd8c63e332f0b6c98ef5dcd01952bfe0c8540081b4c53ece6 new file mode 100644 index 00000000..c6f15c9e --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/119e3be777940bcf8f16f4d087987abfda338f1cdfdbf9faacca1935951d3c30948a794af2b9e26dd8c63e332f0b6c98ef5dcd01952bfe0c8540081b4c53ece6 @@ -0,0 +1,84 @@ +// Copyright 2023-2026 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.harness; + +import "buf/validate/conformance/harness/harness.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/descriptor.proto"; + +// ResultOptions are the options passed to the test runner to configure the +// test run. +message ResultOptions { + // The suite filter is a regex that matches against the suite name. + string suite_filter = 1; + // The case filter is a regex that matches against the case name. + string case_filter = 2; + // If the test runner should print verbose output. + bool verbose = 3; + // If the violation message must be an exact match. + bool strict_message = 5; + // If the distinction between runtime and compile time errors must be exact. + bool strict_error = 6; + reserved 4; + reserved "strict"; +} + +// A result is the result of a test run. +message ResultSet { + // Count of successes. + int32 successes = 1; + // Count of failures. + int32 failures = 2; + // List of suite results. + repeated SuiteResults suites = 3; + // Options used to generate this result. + ResultOptions options = 4; + // Count of expected failures. + int32 expected_failures = 5; +} + +// A suite result is a single test suite result. +message SuiteResults { + // The suite name. + string name = 1; + // Count of successes. + int32 successes = 2; + // Count of failures. + int32 failures = 3; + // List of case results. + repeated CaseResult cases = 4; + // The file descriptor set used to generate this result. + google.protobuf.FileDescriptorSet fdset = 5; + // Count of expected failures. + int32 expected_failures = 6; +} + +// A case result is a single test case result. +message CaseResult { + // The case name. + string name = 1; + // Success state of the test case. True if the test case succeeded. + bool success = 2; + // The expected result. + TestResult wanted = 3; + // The actual result. + TestResult got = 4; + // The input used to invoke the test case. + google.protobuf.Any input = 5; + // Denotes if the test is expected to fail. True, if the test case was expected to fail. + bool expected_failure = 6; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/2703ee45cd2cb25ddfb99b5e52e86bacc8daff3816b87125d9b598d3711bd76b8ca032d6e41eefe3ad089e49512638bcf46adb096dc01b319ff62edf8704aa7e b/modules/sync/bufbuild/protovalidate-testing/cas/2703ee45cd2cb25ddfb99b5e52e86bacc8daff3816b87125d9b598d3711bd76b8ca032d6e41eefe3ad089e49512638bcf46adb096dc01b319ff62edf8704aa7e new file mode 100644 index 00000000..7d37e31f --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/2703ee45cd2cb25ddfb99b5e52e86bacc8daff3816b87125d9b598d3711bd76b8ca032d6e41eefe3ad089e49512638bcf46adb096dc01b319ff62edf8704aa7e @@ -0,0 +1,58 @@ +// Copyright 2023-2026 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 TestOneofMsg { + bool val = 1 [(buf.validate.field).bool.const = true]; +} + +message OneofNone { + oneof o { + string x = 1; + int32 y = 2; + } +} + +message Oneof { + oneof o { + string x = 1 [(buf.validate.field).string.prefix = "foo"]; + int32 y = 2 [(buf.validate.field).int32.gt = 0]; + TestOneofMsg z = 3; + } +} + +message OneofRequired { + oneof o { + option (buf.validate.oneof).required = true; + + string x = 1; + int32 y = 2; + int32 name_with_underscores = 3; + int32 under_and_1_number = 4; + } +} + +message OneofRequiredWithRequiredField { + oneof o { + option (buf.validate.oneof).required = true; + + string a = 1 [(buf.validate.field).required = true]; + string b = 2; + } +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/2ba4662d4db303fca65851583776d6e075dc5746c1022a99eabfa194527c045f4a08e117a90a3f3d6ca1862340250b6807f177e3c7ab9443af98405f7009f43b b/modules/sync/bufbuild/protovalidate-testing/cas/2ba4662d4db303fca65851583776d6e075dc5746c1022a99eabfa194527c045f4a08e117a90a3f3d6ca1862340250b6807f177e3c7ab9443af98405f7009f43b new file mode 100644 index 00000000..fc14dab9 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/2ba4662d4db303fca65851583776d6e075dc5746c1022a99eabfa194527c045f4a08e117a90a3f3d6ca1862340250b6807f177e3c7ab9443af98405f7009f43b @@ -0,0 +1,322 @@ +// Copyright 2023-2026 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 Proto2ScalarOptionalIgnoreUnspecified { + optional int32 val = 1 [(buf.validate.field).int32.gt = 0]; +} + +message Proto2ScalarOptionalIgnoreUnspecifiedWithDefault { + optional int32 val = 1 [ + (buf.validate.field).int32.gt = 0, + default = -42 + ]; +} + +message Proto2ScalarOptionalIgnoreEmpty { + optional int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +message Proto2ScalarOptionalIgnoreEmptyWithDefault { + optional int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0, + default = -42 + ]; +} + +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]; +} + +message Proto2ScalarRequiredIgnoreUnspecifiedWithDefault { + required int32 val = 1 [ + (buf.validate.field).int32.gt = 0, + default = -42 + ]; +} + +message Proto2ScalarRequiredIgnoreEmpty { + required int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +message Proto2ScalarRequiredIgnoreEmptyWithDefault { + required int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0, + default = -42 + ]; +} + +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" + message: "foobar" + expression: "this.val == 'foo'" + }]; + message Msg { + optional string val = 1; + } +} + +message Proto2MessageOptionalIgnoreEmpty { + optional Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).cel = { + id: "proto2.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + optional string val = 1; + } +} + +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" + message: "foobar" + expression: "this.val == 'foo'" + }]; + message Msg { + optional string val = 1; + } +} + +message Proto2MessageRequiredIgnoreEmpty { + required Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).cel = { + id: "proto2.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + optional string val = 1; + } +} + +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]; + } +} + +message Proto2OneofIgnoreUnspecifiedWithDefault { + oneof o { + int32 val = 1 [ + (buf.validate.field).int32.gt = 0, + default = -42 + ]; + } +} + +message Proto2OneofIgnoreEmpty { + oneof o { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; + } +} + +message Proto2OneofIgnoreEmptyWithDefault { + oneof o { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0, + default = -42 + ]; + } +} + +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]; +} + +message Proto2RepeatedIgnoreEmpty { + repeated int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message Proto2RepeatedIgnoreAlways { + repeated int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message Proto2MapIgnoreUnspecified { + map val = 1 [(buf.validate.field).map.min_pairs = 3]; +} + +message Proto2MapIgnoreEmpty { + map val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).map.min_pairs = 3 + ]; +} + +message Proto2MapIgnoreAlways { + map 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]; +} + +message Proto2RepeatedItemIgnoreEmpty { + repeated int32 val = 1 [ + (buf.validate.field).repeated.items.ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).repeated.items.int32.gt = 0 + ]; +} + +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 val = 1 [(buf.validate.field).map.keys.int32.gt = 0]; +} + +message Proto2MapKeyIgnoreEmpty { + map val = 1 [ + (buf.validate.field).map.keys.ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).map.keys.int32.gt = 0 + ]; +} + +message Proto2MapKeyIgnoreAlways { + map val = 1 [ + (buf.validate.field).map.keys.ignore = IGNORE_ALWAYS, + (buf.validate.field).map.keys.int32.gt = 0 + ]; +} + +message Proto2MapValueIgnoreUnspecified { + map val = 1 [(buf.validate.field).map.values.int32.gt = 0]; +} + +message Proto2MapValueIgnoreEmpty { + map val = 1 [ + (buf.validate.field).map.values.ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).map.values.int32.gt = 0 + ]; +} + +message Proto2MapValueIgnoreAlways { + map val = 1 [ + (buf.validate.field).map.values.ignore = IGNORE_ALWAYS, + (buf.validate.field).map.values.int32.gt = 0 + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/30dbfdb857aa9ddee35f3cafc27ee186dc01e2a1ef242f1d317fe4ad2a9b431fcd78a701e86fade1d13d9614b1ca846e7b1e83f0d84ef2372ed585cc8d9efced b/modules/sync/bufbuild/protovalidate-testing/cas/30dbfdb857aa9ddee35f3cafc27ee186dc01e2a1ef242f1d317fe4ad2a9b431fcd78a701e86fade1d13d9614b1ca846e7b1e83f0d84ef2372ed585cc8d9efced new file mode 100644 index 00000000..d2a988df --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/30dbfdb857aa9ddee35f3cafc27ee186dc01e2a1ef242f1d317fe4ad2a9b431fcd78a701e86fade1d13d9614b1ca846e7b1e83f0d84ef2372ed585cc8d9efced @@ -0,0 +1,29 @@ +// Copyright 2023-2026 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.yet_another_package; + +import "buf/validate/validate.proto"; + +// Validate message embedding across packages. +message Embed { + int64 val = 1 [(buf.validate.field).int64.gt = 0]; + + enum Enumerated { + ENUMERATED_UNSPECIFIED = 0; + ENUMERATED_VALUE = 1; + } +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/32cdfa6e197630040ce8e16ac9682f57eb77c6ba75c6431ba1405d70c906f1265dcedf4fba84204f7ad3de03cecddc0821737e28dab0e5b9ab0b9f4b4ccdc173 b/modules/sync/bufbuild/protovalidate-testing/cas/32cdfa6e197630040ce8e16ac9682f57eb77c6ba75c6431ba1405d70c906f1265dcedf4fba84204f7ad3de03cecddc0821737e28dab0e5b9ab0b9f4b4ccdc173 new file mode 100644 index 00000000..b9816ea7 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/32cdfa6e197630040ce8e16ac9682f57eb77c6ba75c6431ba1405d70c906f1265dcedf4fba84204f7ad3de03cecddc0821737e28dab0e5b9ab0b9f4b4ccdc173 @@ -0,0 +1,116 @@ +// Copyright 2023-2026 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"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +message DurationNone { + google.protobuf.Duration val = 1; +} + +message DurationRequired { + google.protobuf.Duration val = 1 [(buf.validate.field).required = true]; +} + +message DurationConst { + google.protobuf.Duration val = 1 [(buf.validate.field).duration.const = {seconds: 3}]; +} + +message DurationIn { + google.protobuf.Duration val = 1 [(buf.validate.field).duration = { + in: [ + {seconds: 1}, + {nanos: 1000}] + }]; +} +message DurationNotIn { + google.protobuf.Duration val = 1 [(buf.validate.field).duration = { + not_in: [ + {}] + }]; +} + +message DurationLT { + google.protobuf.Duration val = 1 [(buf.validate.field).duration.lt = {}]; +} +message DurationLTE { + google.protobuf.Duration val = 1 [(buf.validate.field).duration.lte = {seconds: 1}]; +} +message DurationGT { + google.protobuf.Duration val = 1 [(buf.validate.field).duration.gt = {nanos: 1000}]; +} +message DurationGTE { + google.protobuf.Duration val = 1 [(buf.validate.field).duration.gte = {nanos: 1000000}]; +} +message DurationGTLT { + google.protobuf.Duration val = 1 [(buf.validate.field).duration = { + gt: {} + lt: {seconds: 1} + }]; +} +message DurationExLTGT { + google.protobuf.Duration val = 1 [(buf.validate.field).duration = { + lt: {} + gt: {seconds: 1} + }]; +} +message DurationGTELTE { + google.protobuf.Duration val = 1 [(buf.validate.field).duration = { + gte: {seconds: 60} + lte: {seconds: 3600} + }]; +} +message DurationExGTELTE { + google.protobuf.Duration val = 1 [(buf.validate.field).duration = { + lte: {seconds: 60} + gte: {seconds: 3600} + }]; +} + +// Regression for earlier bug where missing Duration field would short circuit +// evaluation in C++. +message DurationFieldWithOtherFields { + google.protobuf.Duration duration_val = 1 [(buf.validate.field).duration.lte = {seconds: 1}]; + int32 int_val = 2 [(buf.validate.field).int32.gt = 16]; +} + +message DurationExample { + google.protobuf.Duration val = 1 [(buf.validate.field).duration.example = {seconds: 3}]; +} + +// The below messages should throw compilation errors due to incorrect types. +message DurationWrongTypeScalar { + int32 seconds = 1 [(buf.validate.field).duration.lte = {seconds: 1}]; +} + +message DurationWrongTypeMessage { + message WrongType { + int32 seconds = 1; + } + WrongType val = 1 [(buf.validate.field).duration.lte = {seconds: 1}]; +} + +message DurationWrongTypeWrapper { + google.protobuf.Int32Value val = 1 [(buf.validate.field).duration.example = {seconds: 3}]; +} + +message DurationWrongTypeWKT { + google.protobuf.Timestamp val = 1 [(buf.validate.field).duration.example = {seconds: 3}]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/3a0a6e2c011a5912ca6b353d5fbefae22cb330ae1b7228428051b359b813bfa51660f7c2092ebf95c7936ebd1154bcb2d394d2e35629dbc7274aaaecac19e89a b/modules/sync/bufbuild/protovalidate-testing/cas/3a0a6e2c011a5912ca6b353d5fbefae22cb330ae1b7228428051b359b813bfa51660f7c2092ebf95c7936ebd1154bcb2d394d2e35629dbc7274aaaecac19e89a new file mode 100644 index 00000000..e5b46d74 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/3a0a6e2c011a5912ca6b353d5fbefae22cb330ae1b7228428051b359b813bfa51660f7c2092ebf95c7936ebd1154bcb2d394d2e35629dbc7274aaaecac19e89a @@ -0,0 +1,19 @@ +// Copyright 2023-2026 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"; diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/3d8688d9453f5a9dc70c9685da563d93751ec219fe29f1f42a9b237daf185bd8ad52025b35e938da5a56601817f48f892b9025f6a431c0563c27a51ed76ff160 b/modules/sync/bufbuild/protovalidate-testing/cas/3d8688d9453f5a9dc70c9685da563d93751ec219fe29f1f42a9b237daf185bd8ad52025b35e938da5a56601817f48f892b9025f6a431c0563c27a51ed76ff160 new file mode 100644 index 00000000..b7ca36a7 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/3d8688d9453f5a9dc70c9685da563d93751ec219fe29f1f42a9b237daf185bd8ad52025b35e938da5a56601817f48f892b9025f6a431c0563c27a51ed76ff160 @@ -0,0 +1,123 @@ +// Copyright 2023-2026 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"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +message TimestampNone { + google.protobuf.Timestamp val = 1; +} +message TimestampRequired { + google.protobuf.Timestamp val = 1 [(buf.validate.field).required = true]; +} +message TimestampConst { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.const = {seconds: 3}]; +} + +message TimestampLT { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.lt = {}]; +} +message TimestampLTE { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.lte = {seconds: 1}]; +} +message TimestampGT { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.gt = {nanos: 1000}]; +} +message TimestampGTE { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.gte = {nanos: 1000000}]; +} +message TimestampGTLT { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp = { + gt: {} + lt: {seconds: 1} + }]; +} +message TimestampExLTGT { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp = { + lt: {} + gt: {seconds: 1} + }]; +} +message TimestampGTELTE { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp = { + gte: {seconds: 60} + lte: {seconds: 3600} + }]; +} +message TimestampExGTELTE { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp = { + lte: {seconds: 60} + gte: {seconds: 3600} + }]; +} + +message TimestampLTNow { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.lt_now = true]; +} +message TimestampNotLTNow { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.lt_now = false]; +} +message TimestampGTNow { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.gt_now = true]; +} +message TimestampNotGTNow { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.gt_now = false]; +} + +message TimestampWithin { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.within.seconds = 3600]; +} + +message TimestampLTNowWithin { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp = { + lt_now: true + within: {seconds: 3600} + }]; +} +message TimestampGTNowWithin { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp = { + gt_now: true + within: {seconds: 3600} + }]; +} + +message TimestampExample { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.example = {seconds: 3}]; +} + +// The below messages should throw compilation errors due to rules being applied toincorrect types. +message TimestampWrongTypeScalar { + int32 val = 1 [(buf.validate.field).timestamp.lt_now = true]; +} + +message TimestampWrongTypeMessage { + message WrongType { + int32 val = 1; + } + WrongType val = 1 [(buf.validate.field).timestamp.lt_now = true]; +} + +message TimestampWrongTypeWrapper { + google.protobuf.Int32Value val = 1 [(buf.validate.field).timestamp.lt_now = true]; +} + +message TimestampWrongTypeWKT { + google.protobuf.Duration val = 1 [(buf.validate.field).timestamp.lt_now = true]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/4655dc847b6eb7bc68fc2b1ba93229333345a44fc7033b95ab03c235b5ebdc5374f6c64711daa92cdaf35315822f1a5b15eed6ac9abc7434ffc745ec7e39c6df b/modules/sync/bufbuild/protovalidate-testing/cas/4655dc847b6eb7bc68fc2b1ba93229333345a44fc7033b95ab03c235b5ebdc5374f6c64711daa92cdaf35315822f1a5b15eed6ac9abc7434ffc745ec7e39c6df new file mode 100644 index 00000000..4d749ec4 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/4655dc847b6eb7bc68fc2b1ba93229333345a44fc7033b95ab03c235b5ebdc5374f6c64711daa92cdaf35315822f1a5b15eed6ac9abc7434ffc745ec7e39c6df @@ -0,0 +1,90 @@ +// Copyright 2023-2026 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 = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyProto3OptionalScalar { + optional int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyProto3Message { + optional Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (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 = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; + } +} + +message IgnoreEmptyProto3Repeated { + repeated int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message IgnoreEmptyProto3Map { + map val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).map.min_pairs = 3 + ]; +} + +message IgnoreEmptyRepeatedItems { + repeated int32 val = 1 [(buf.validate.field).repeated.items = { + ignore: IGNORE_IF_ZERO_VALUE + int32: {gt: 0} + }]; +} + +message IgnoreEmptyMapPairs { + map val = 1 [ + (buf.validate.field).map.keys = { + ignore: IGNORE_IF_ZERO_VALUE + string: {min_len: 3} + }, + (buf.validate.field).map.values = { + ignore: IGNORE_IF_ZERO_VALUE + int32: {gt: 0} + } + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/46ea994e1a721a88047c54bfbb7fd9696cb51df07c03745828a8616381151a1ecc7e4fb734cb19257e1d1beaf4072a3ca404393bb2719bb7e1846773acb06a36 b/modules/sync/bufbuild/protovalidate-testing/cas/46ea994e1a721a88047c54bfbb7fd9696cb51df07c03745828a8616381151a1ecc7e4fb734cb19257e1d1beaf4072a3ca404393bb2719bb7e1846773acb06a36 new file mode 100644 index 00000000..5a5cb38c --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/46ea994e1a721a88047c54bfbb7fd9696cb51df07c03745828a8616381151a1ecc7e4fb734cb19257e1d1beaf4072a3ca404393bb2719bb7e1846773acb06a36 @@ -0,0 +1,41 @@ +shake256:e702a95ca4516da9365b47a96282a3997660ecff5f614135d19a480ae7e9fb7fc0780efa034d133b95f5fe214a9fe4dd1cd65a9a9b6362db5f07792c0b699f38 LICENSE +shake256:f8ff39133ea099de75154fa52f13462d05b5e1c51ce96c5626aaae1e1e70b5cf6538fa6e1914bcfee969379bc93ec77772d44162672e868e9f26848a4b007420 README.md +shake256:1034dfb38b6a31504705889b6bc529fc182794da79ba1b7440d4b403edfc4467381f20b635b26eb42913887eb5e48841ed5f7ce3f8542339c99e58bdc90cef83 buf.yaml +shake256:99047ed1eddac0b6ab7063ceb2a52b6b429da9d42f3ceddd431f59d23675c85ba1bacb1f8f8e49397833c961e580720055b3c86af5bba972e664da7f6d91e86f buf/validate/conformance/cases/bool.proto +shake256:021ad16ef72d5244906bf3b69de9a4eed623a50661406eee9c847f5f2d4fbcacba91c3895d8d84e4836776a9fd93b250cad5d9c908dcce5e1e29bf91d56cc21f buf/validate/conformance/cases/bytes.proto +shake256:f3acd2b171af96911432ac42c55a9fec37eaf1429e5fe72b5430c00ab36716b19443aaf78cd7cdb5b0a54b546a5f6cdd32b8f94ae1150fd9c291165adb6778c0 buf/validate/conformance/cases/custom_rules/custom_rules.proto +shake256:e8db08f636106e6716c3a89bfa18a47dec10b47bd93801105861aec280e8deb21205a1f0bb28d9f58c76fbd9517ec9a9f206b0e6216eb019938d23432bfcbdba buf/validate/conformance/cases/enums.proto +shake256:3a0a6e2c011a5912ca6b353d5fbefae22cb330ae1b7228428051b359b813bfa51660f7c2092ebf95c7936ebd1154bcb2d394d2e35629dbc7274aaaecac19e89a buf/validate/conformance/cases/filename-with-dash.proto +shake256:75ceb0ab3ae7d9a8664b5a65d2f7c2fb9ceb48d351b02cf05af91de1a25fab9b873b8cc388b4117cef064c7c12ad573d55bfa741bcdf868213212c945a11822f buf/validate/conformance/cases/groups_editions.proto +shake256:4a5e780e6a4f4d8f60bd17f580e0e2a02910a7e01d7a539e8f921623180168ba2b4819aad0c9764023e8b89ec1f144a8ca70f1dc593e6d2c396d40a7f056f4d2 buf/validate/conformance/cases/groups_proto2.proto +shake256:5a0d68a0eabe5c3c43d9304adc448ef907a56d64017430b904aca9695718824f964015d9e82a5a06298a7ef9c60456ce51f5dbae85f3e59ab5635a63a449e4aa buf/validate/conformance/cases/ignore_empty_proto2.proto +shake256:4655dc847b6eb7bc68fc2b1ba93229333345a44fc7033b95ab03c235b5ebdc5374f6c64711daa92cdaf35315822f1a5b15eed6ac9abc7434ffc745ec7e39c6df buf/validate/conformance/cases/ignore_empty_proto3.proto +shake256:9269552129342bb2bc922f89dda22c31a3e9532154d1fca27efb20f17a7ad43a0c225a0ba7596b2531f46cdd06b1bf4dfc825dbfc97a6fa7345d2a1e19280cd3 buf/validate/conformance/cases/ignore_empty_proto_editions.proto +shake256:2ba4662d4db303fca65851583776d6e075dc5746c1022a99eabfa194527c045f4a08e117a90a3f3d6ca1862340250b6807f177e3c7ab9443af98405f7009f43b buf/validate/conformance/cases/ignore_proto2.proto +shake256:6a1a59a042a08516a5a7620714148e94fa9fff0dfbd8b71af99c15cfeb9791c7bc7a8bd6573a02ba9a21124f836d80845b0623e5ddf3fae2ea61dbdd1434f4d3 buf/validate/conformance/cases/ignore_proto3.proto +shake256:b378199efb09514bf23931c73626f091b2512e4c3fa3e4d8fb0682bfe8bbd5570a9ac20ca6499fd31b173ba73bb6d3bec6442c0fdd9c91fa402fa45e7aff4c10 buf/validate/conformance/cases/ignore_proto_editions.proto +shake256:e790f9ea5503a6955f45c45dcb8a5700d35846e36600b08c0471d66f6062b4f2c3479220c0b7be814c6888bfff0f3dcc051c09a84545aa39ca566d79f7e8de40 buf/validate/conformance/cases/kitchen_sink.proto +shake256:7bb300d336cfa0156b468667169b00a50beca4e42a02cfa466aaa35460eddae7c824ff7edaa670443dd97c094c01bec61f4b742b571b4d970aec933998a5845e buf/validate/conformance/cases/library.proto +shake256:d95e4d1e9ab99dd39fa6fcea8b206a9fea5ad3891741139dab1bc13010bacae2e6e7e35b96d4a0104ef958cc2622bc0a59d3ef66517d7d22672b28b11ec22943 buf/validate/conformance/cases/maps.proto +shake256:7969e46bcc89b0c6ed3f99d5c66e107521a24b0ad7716949d44b4bd64e1efab0a01955b7a3061b82eccaad514b18a4c48d94daf0d8273fa5505e19b85829f198 buf/validate/conformance/cases/messages.proto +shake256:5e75dc4322af2cf380488f172a051882a426d197a849163c32c16479ed5ca88e4e83b2bad4dea9167e32ebab6e91f77fef0fa1b23dc3ca92ec28533a0f8ec10d buf/validate/conformance/cases/numbers.proto +shake256:2703ee45cd2cb25ddfb99b5e52e86bacc8daff3816b87125d9b598d3711bd76b8ca032d6e41eefe3ad089e49512638bcf46adb096dc01b319ff62edf8704aa7e buf/validate/conformance/cases/oneofs.proto +shake256:9c90cb9d680419cd0415b76d45deec686d98616083f8abee38bdda797ea332a59b4af37bcb642de0796b2ac406476b28603b49e481a839a024958515adec1e7b buf/validate/conformance/cases/other_package/embed.proto +shake256:f93514ac3a94aba4b51099c349a8ff1ff7016cc04162573177d7aba8eebd4c1984819fd429f3e3cd3db5e5efd1d828d304dd05e24e28e05fa508362a6b513aeb buf/validate/conformance/cases/predefined_rules_proto2.proto +shake256:bea010505fbf083ab86ec3a6b6b5c94c7abaff58ca5460817e31a406831ad4ac4fab42f0de0ce2fa3f712fea72cb5d2510a2d225d2f6f2b8593ce3c2d4869e36 buf/validate/conformance/cases/predefined_rules_proto3.proto +shake256:53f67f08548ff6a853fad4e87171cafe1e90a62ed469ba368453e88be9064a4b2dc7d15921b4aefa3925e04660839f1cdca237d6672d9bcf42ebbf92b60b6919 buf/validate/conformance/cases/predefined_rules_proto_editions.proto +shake256:ca0148e4a87f4b3e50df8a2786c81af6cfd50b3634aeb5e09dadeca86e30604ff851e392476d65f8fbaff0c6ccdddf4e25c7d5b5cf3bb9987912feb051ac9c5b buf/validate/conformance/cases/repeated.proto +shake256:a82ceea3b542e392624be12293788d4fa1bf88e487e567f3ace688fd55b4b73dd11104e91917f9c1866b68b6c611d5f2c9505e73e93e5e2903e7a2aba26b3cb5 buf/validate/conformance/cases/required_field_proto2.proto +shake256:0778d32a5e2a64156a45907acccb3c6ce84da912034f15425ad30136b44f67f6a900f9e28fea0ea112813526b9b3bf1f8e89fdc1be8352d4d7e888f1980b78b6 buf/validate/conformance/cases/required_field_proto3.proto +shake256:9f2a9fed6dfb460fff19f964b6c1f529118793f094e00c07b04501e5553ed331485076570bdb278b0a83420d8d296d0995922f83cb441f1aa9fceabc7302b494 buf/validate/conformance/cases/required_field_proto_editions.proto +shake256:b7fcdf6e69bf02bd3fbe0e9412f1e6b5aa36c0a1af20a82280b1bbecea8d5d64493baaae8d6c12ddbaafb77651c7b2119fc9411eb4883dc3ea2c2470b8bc3ee4 buf/validate/conformance/cases/strings.proto +shake256:cc2374179d58436e4ad321d075df99b2ba42fce4334c8a06e3fd6ccfe476d14e7aea4263bd9755db061ba7c826ba44497d614ebc480aa750799192b0172655bb buf/validate/conformance/cases/subdirectory/in_subdirectory.proto +shake256:d194a33bd8dc13bd7b56db8c4793c548cc2d3deebf1a49c98213b9f424e4454c1df5d8d6301a3a3884dad881a642eafb739e16b499fec99649ca0dc46e9c5408 buf/validate/conformance/cases/wkt_any.proto +shake256:32cdfa6e197630040ce8e16ac9682f57eb77c6ba75c6431ba1405d70c906f1265dcedf4fba84204f7ad3de03cecddc0821737e28dab0e5b9ab0b9f4b4ccdc173 buf/validate/conformance/cases/wkt_duration.proto +shake256:e5726d498e20865b97300411c0ce44a02fca0f6879ed59606e0e83aed0679e23ddf6e1da724fdb9e613b5c9782b7a3791ed127eddbdf60b1268b48cb56b33385 buf/validate/conformance/cases/wkt_field_mask.proto +shake256:de0ade06ce5a50c5a971fb235ff8536244d1783e80309c686102e49fd0363956cfa8dec44975c25794224df5c65220f71d42bdd787aae42a4d0843c3d9c2711f buf/validate/conformance/cases/wkt_nested.proto +shake256:3d8688d9453f5a9dc70c9685da563d93751ec219fe29f1f42a9b237daf185bd8ad52025b35e938da5a56601817f48f892b9025f6a431c0563c27a51ed76ff160 buf/validate/conformance/cases/wkt_timestamp.proto +shake256:7282dfa1b32ce707d079e04c4c1dae8df7ad70c559a4e1ef6ccde76d45300cb5ba18a92f04d09eaa54365cf589f914c76677d98efec4a9836c192d63adf73fad buf/validate/conformance/cases/wkt_wrappers.proto +shake256:30dbfdb857aa9ddee35f3cafc27ee186dc01e2a1ef242f1d317fe4ad2a9b431fcd78a701e86fade1d13d9614b1ca846e7b1e83f0d84ef2372ed585cc8d9efced buf/validate/conformance/cases/yet_another_package/embed2.proto +shake256:63e330e4e445174e10e14c3f1b7a0681210297f24e8dce5786f3763333989c4babcf75ac8e38c8cafe712ca0ddfd37b6de06e4de17e637f5b531789b73899073 buf/validate/conformance/harness/harness.proto +shake256:119e3be777940bcf8f16f4d087987abfda338f1cdfdbf9faacca1935951d3c30948a794af2b9e26dd8c63e332f0b6c98ef5dcd01952bfe0c8540081b4c53ece6 buf/validate/conformance/harness/results.proto diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/4a5e780e6a4f4d8f60bd17f580e0e2a02910a7e01d7a539e8f921623180168ba2b4819aad0c9764023e8b89ec1f144a8ca70f1dc593e6d2c396d40a7f056f4d2 b/modules/sync/bufbuild/protovalidate-testing/cas/4a5e780e6a4f4d8f60bd17f580e0e2a02910a7e01d7a539e8f921623180168ba2b4819aad0c9764023e8b89ec1f144a8ca70f1dc593e6d2c396d40a7f056f4d2 new file mode 100644 index 00000000..b963594b --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/4a5e780e6a4f4d8f60bd17f580e0e2a02910a7e01d7a539e8f921623180168ba2b4819aad0c9764023e8b89ec1f144a8ca70f1dc593e6d2c396d40a7f056f4d2 @@ -0,0 +1,49 @@ +// Copyright 2023-2026 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 GroupOptional { + optional group Optional = 1 { + optional string value = 1 [(buf.validate.field).string.const = "foo"]; + } +} + +message GroupRepeated { + repeated group Repeated = 1 { + optional int32 value = 1 [(buf.validate.field).int32.gt = 0]; + } +} + +message GroupRequired { + required group Required = 1 { + optional bool value = 1 [(buf.validate.field).bool.const = true]; + } +} + +message GroupCustom { + optional group Custom = 1 { + option (buf.validate.message).cel = { + id: "group.custom.div" + message: "value must be divisible by div" + expression: "this.value % this.div == 0" + }; + optional int32 value = 1; + optional int32 div = 2; + } +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/53f67f08548ff6a853fad4e87171cafe1e90a62ed469ba368453e88be9064a4b2dc7d15921b4aefa3925e04660839f1cdca237d6672d9bcf42ebbf92b60b6919 b/modules/sync/bufbuild/protovalidate-testing/cas/53f67f08548ff6a853fad4e87171cafe1e90a62ed469ba368453e88be9064a4b2dc7d15921b4aefa3925e04660839f1cdca237d6672d9bcf42ebbf92b60b6919 new file mode 100644 index 00000000..726b3e00 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/53f67f08548ff6a853fad4e87171cafe1e90a62ed469ba368453e88be9064a4b2dc7d15921b4aefa3925e04660839f1cdca237d6672d9bcf42ebbf92b60b6919 @@ -0,0 +1,373 @@ +// Copyright 2023-2026 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. + +edition = "2023"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +extend buf.validate.FloatRules { + float float_abs_range_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "float.abs_range.edition_2023" + expression: "this >= -rule && this <= rule" + message: "float value is out of range" + }]; +} + +extend buf.validate.DoubleRules { + double double_abs_range_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "double.abs_range.edition_2023" + expression: "this >= -rule && this <= rule" + message: "double value is out of range" + }]; +} + +extend buf.validate.Int32Rules { + repeated int32 int32_abs_in_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "int32.abs_in.edition_2023" + expression: "this in rule || this in rule.map(n, -n)" + message: "value must be in absolute value of list" + }]; +} + +extend buf.validate.Int64Rules { + repeated google.protobuf.Int64Value int64_abs_in_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "int64.abs_in.edition_2023" + expression: "this in rule || this in rule.map(n, -n)" + message: "value must be in absolute value of list" + }]; +} + +extend buf.validate.UInt32Rules { + bool uint32_even_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "uint32.even.edition_2023" + expression: "this % 2u == 0u" + message: "uint32 value is not even" + }]; +} + +extend buf.validate.UInt64Rules { + bool uint64_even_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "uint64.even.edition_2023" + expression: "this % 2u == 0u" + message: "uint64 value is not even" + }]; +} + +extend buf.validate.SInt32Rules { + bool sint32_even_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "sint32.even.edition_2023" + expression: "this % 2 == 0" + message: "sint32 value is not even" + }]; +} + +extend buf.validate.SInt64Rules { + bool sint64_even_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "sint64.even.edition_2023" + expression: "this % 2 == 0" + message: "sint64 value is not even" + }]; +} + +extend buf.validate.Fixed32Rules { + bool fixed32_even_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "fixed32.even.edition_2023" + expression: "this % 2u == 0u" + message: "fixed32 value is not even" + }]; +} + +extend buf.validate.Fixed64Rules { + bool fixed64_even_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "fixed64.even.edition_2023" + expression: "this % 2u == 0u" + message: "fixed64 value is not even" + }]; +} + +extend buf.validate.SFixed32Rules { + bool sfixed32_even_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "sfixed32.even.edition_2023" + expression: "this % 2 == 0" + message: "sfixed32 value is not even" + }]; +} + +extend buf.validate.SFixed64Rules { + bool sfixed64_even_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "sfixed64.even.edition_2023" + expression: "this % 2 == 0" + message: "sfixed64 value is not even" + }]; +} + +extend buf.validate.BoolRules { + bool bool_false_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "bool.false.edition_2023" + expression: "this == false" + message: "bool value is not false" + }]; +} + +extend buf.validate.StringRules { + bool string_valid_path_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "string.valid_path.edition_2023" + expression: "!this.matches('^([^/.][^/]?|[^/][^/.]|[^/]{3,})(/([^/.][^/]?|[^/][^/.]|[^/]{3,}))*$') ? 'not a valid path: `%s`'.format([this]) : ''" + }]; +} + +extend buf.validate.BytesRules { + bool bytes_valid_path_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "bytes.valid_path.edition_2023" + expression: "!string(this).matches('^([^/.][^/]?|[^/][^/.]|[^/]{3,})(/([^/.][^/]?|[^/][^/.]|[^/]{3,}))*$') ? 'not a valid path: `%s`'.format([this]) : ''" + }]; +} + +extend buf.validate.EnumRules { + bool enum_non_zero_edition_2023 = 1162 [(buf.validate.predefined).cel = { + id: "enum.non_zero.edition_2023" + expression: "int(this) != 0" + message: "enum value is not non-zero" + }]; +} + +extend buf.validate.RepeatedRules { + bool repeated_at_least_five_edition_2023 = 1162 [(predefined).cel = { + id: "repeated.at_least_five.edition_2023" + expression: "uint(this.size()) >= 5u" + message: "repeated field must have at least five values" + }]; +} + +extend buf.validate.MapRules { + bool map_at_least_five_edition_2023 = 1162 [(predefined).cel = { + id: "map.at_least_five.edition_2023" + expression: "uint(this.size()) >= 5u" + message: "map must have at least five pairs" + }]; +} + +extend buf.validate.DurationRules { + bool duration_too_long_edition_2023 = 1162 [(predefined).cel = { + id: "duration.too_long.edition_2023" + expression: "this <= duration('10s')" + message: "duration can't be longer than 10 seconds" + }]; +} + +extend buf.validate.TimestampRules { + bool timestamp_in_range_edition_2023 = 1162 [(predefined).cel = { + id: "timestamp.time_range.edition_2023" + expression: "int(this) >= 1049587200 && int(this) <= 1080432000" + message: "timestamp out of range" + }]; +} + +message PredefinedFloatRuleEdition2023 { + float val = 1 [(buf.validate.field).float.(float_abs_range_edition_2023) = 1.0]; +} + +message PredefinedDoubleRuleEdition2023 { + double val = 1 [(buf.validate.field).double.(double_abs_range_edition_2023) = 1.0]; +} + +message PredefinedInt32RuleEdition2023 { + int32 val = 1 [(buf.validate.field).int32.(int32_abs_in_edition_2023) = -2]; +} + +message PredefinedInt64RuleEdition2023 { + int64 val = 1 [(buf.validate.field).int64.(int64_abs_in_edition_2023) = {value: -2}]; +} + +message PredefinedUInt32RuleEdition2023 { + uint32 val = 1 [(buf.validate.field).uint32.(uint32_even_edition_2023) = true]; +} + +message PredefinedUInt64RuleEdition2023 { + uint64 val = 1 [(buf.validate.field).uint64.(uint64_even_edition_2023) = true]; +} + +message PredefinedSInt32RuleEdition2023 { + sint32 val = 1 [(buf.validate.field).sint32.(sint32_even_edition_2023) = true]; +} + +message PredefinedSInt64RuleEdition2023 { + sint64 val = 1 [(buf.validate.field).sint64.(sint64_even_edition_2023) = true]; +} + +message PredefinedFixed32RuleEdition2023 { + fixed32 val = 1 [(buf.validate.field).fixed32.(fixed32_even_edition_2023) = true]; +} + +message PredefinedFixed64RuleEdition2023 { + fixed64 val = 1 [(buf.validate.field).fixed64.(fixed64_even_edition_2023) = true]; +} + +message PredefinedSFixed32RuleEdition2023 { + sfixed32 val = 1 [(buf.validate.field).sfixed32.(sfixed32_even_edition_2023) = true]; +} + +message PredefinedSFixed64RuleEdition2023 { + sfixed64 val = 1 [(buf.validate.field).sfixed64.(sfixed64_even_edition_2023) = true]; +} + +message PredefinedBoolRuleEdition2023 { + bool val = 1 [(buf.validate.field).bool.(bool_false_edition_2023) = true]; +} + +message PredefinedStringRuleEdition2023 { + string val = 1 [(buf.validate.field).string.(string_valid_path_edition_2023) = true]; +} + +message PredefinedBytesRuleEdition2023 { + bytes val = 1 [(buf.validate.field).bytes.(bytes_valid_path_edition_2023) = true]; +} + +message PredefinedEnumRuleEdition2023 { + enum EnumEdition2023 { + ENUM_EDITION2023_ZERO_UNSPECIFIED = 0; + ENUM_EDITION2023_ONE = 1; + } + EnumEdition2023 val = 1 [(buf.validate.field).enum.(enum_non_zero_edition_2023) = true]; +} + +message PredefinedRepeatedRuleEdition2023 { + repeated uint64 val = 1 [(buf.validate.field).repeated.(repeated_at_least_five_edition_2023) = true]; +} + +message PredefinedMapRuleEdition2023 { + map val = 1 [(buf.validate.field).map.(map_at_least_five_edition_2023) = true]; +} + +message PredefinedDurationRuleEdition2023 { + google.protobuf.Duration val = 1 [(buf.validate.field).duration.(duration_too_long_edition_2023) = true]; +} + +message PredefinedTimestampRuleEdition2023 { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.(timestamp_in_range_edition_2023) = true]; +} + +message PredefinedWrappedFloatRuleEdition2023 { + google.protobuf.FloatValue val = 1 [(buf.validate.field).float.(float_abs_range_edition_2023) = 1.0]; +} + +message PredefinedWrappedDoubleRuleEdition2023 { + google.protobuf.DoubleValue val = 1 [(buf.validate.field).double.(double_abs_range_edition_2023) = 1.0]; +} + +message PredefinedWrappedInt32RuleEdition2023 { + google.protobuf.Int32Value val = 1 [(buf.validate.field).int32.(int32_abs_in_edition_2023) = -2]; +} + +message PredefinedWrappedInt64RuleEdition2023 { + google.protobuf.Int64Value val = 1 [(buf.validate.field).int64.(int64_abs_in_edition_2023) = {value: -2}]; +} + +message PredefinedWrappedUInt32RuleEdition2023 { + google.protobuf.UInt32Value val = 1 [(buf.validate.field).uint32.(uint32_even_edition_2023) = true]; +} + +message PredefinedWrappedUInt64RuleEdition2023 { + google.protobuf.UInt64Value val = 1 [(buf.validate.field).uint64.(uint64_even_edition_2023) = true]; +} + +message PredefinedWrappedBoolRuleEdition2023 { + google.protobuf.BoolValue val = 1 [(buf.validate.field).bool.(bool_false_edition_2023) = true]; +} + +message PredefinedWrappedStringRuleEdition2023 { + google.protobuf.StringValue val = 1 [(buf.validate.field).string.(string_valid_path_edition_2023) = true]; +} + +message PredefinedWrappedBytesRuleEdition2023 { + google.protobuf.BytesValue val = 1 [(buf.validate.field).bytes.(bytes_valid_path_edition_2023) = true]; +} + +message PredefinedRepeatedWrappedFloatRuleEdition2023 { + repeated google.protobuf.FloatValue val = 1 [(buf.validate.field).repeated.items.float.(float_abs_range_edition_2023) = 1.0]; +} + +message PredefinedRepeatedWrappedDoubleRuleEdition2023 { + repeated google.protobuf.DoubleValue val = 1 [(buf.validate.field).repeated.items.double.(double_abs_range_edition_2023) = 1.0]; +} + +message PredefinedRepeatedWrappedInt32RuleEdition2023 { + repeated google.protobuf.Int32Value val = 1 [(buf.validate.field).repeated.items.int32.(int32_abs_in_edition_2023) = -2]; +} + +message PredefinedRepeatedWrappedInt64RuleEdition2023 { + repeated google.protobuf.Int64Value val = 1 [(buf.validate.field).repeated.items.int64.(int64_abs_in_edition_2023) = {value: -2}]; +} + +message PredefinedRepeatedWrappedUInt32RuleEdition2023 { + repeated google.protobuf.UInt32Value val = 1 [(buf.validate.field).repeated.items.uint32.(uint32_even_edition_2023) = true]; +} + +message PredefinedRepeatedWrappedUInt64RuleEdition2023 { + repeated google.protobuf.UInt64Value val = 1 [(buf.validate.field).repeated.items.uint64.(uint64_even_edition_2023) = true]; +} + +message PredefinedRepeatedWrappedBoolRuleEdition2023 { + repeated google.protobuf.BoolValue val = 1 [(buf.validate.field).repeated.items.bool.(bool_false_edition_2023) = true]; +} + +message PredefinedRepeatedWrappedStringRuleEdition2023 { + repeated google.protobuf.StringValue val = 1 [(buf.validate.field).repeated.items.string.(string_valid_path_edition_2023) = true]; +} + +message PredefinedRepeatedWrappedBytesRuleEdition2023 { + repeated google.protobuf.BytesValue val = 1 [(buf.validate.field).repeated.items.bytes.(bytes_valid_path_edition_2023) = true]; +} + +message PredefinedAndCustomRuleEdition2023 { + sint32 a = 1 [ + (field).cel = { + id: "predefined_and_custom_rule_scalar_edition_2023" + expression: "this > 24 ? '' : 'a must be greater than 24'" + }, + (field).sint32.(sint32_even_edition_2023) = true + ]; + + Nested b = 2 [(field).cel = { + id: "predefined_and_custom_rule_embedded_edition_2023" + message: "b.c must be a multiple of 3" + expression: "this.c % 3 == 0" + }]; + + message Nested { + sint32 c = 1 [ + (field).cel = { + id: "predefined_and_custom_rule_nested_edition_2023" + expression: "this > 0 ? '' : 'c must be positive'" + }, + (field).sint32.(sint32_even_edition_2023) = true + ]; + } +} + +message StandardPredefinedAndCustomRuleEdition2023 { + sint32 a = 1 [ + (field).sint32.lt = 28, + (field).sint32.(sint32_even_edition_2023) = true, + (field).cel = { + id: "standard_predefined_and_custom_rule_scalar_edition_2023" + expression: "this > 24 ? '' : 'a must be greater than 24'" + } + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/5a0d68a0eabe5c3c43d9304adc448ef907a56d64017430b904aca9695718824f964015d9e82a5a06298a7ef9c60456ce51f5dbae85f3e59ab5635a63a449e4aa b/modules/sync/bufbuild/protovalidate-testing/cas/5a0d68a0eabe5c3c43d9304adc448ef907a56d64017430b904aca9695718824f964015d9e82a5a06298a7ef9c60456ce51f5dbae85f3e59ab5635a63a449e4aa new file mode 100644 index 00000000..2c72a2cc --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/5a0d68a0eabe5c3c43d9304adc448ef907a56d64017430b904aca9695718824f964015d9e82a5a06298a7ef9c60456ce51f5dbae85f3e59ab5635a63a449e4aa @@ -0,0 +1,78 @@ +// Copyright 2023-2026 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 = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyProto2ScalarOptionalWithDefault { + optional int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0, + default = 42 + ]; +} + +message IgnoreEmptyProto2ScalarRequired { + required int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyProto2Message { + optional Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (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 = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; + } +} + +message IgnoreEmptyProto2Repeated { + repeated int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message IgnoreEmptyProto2Map { + map val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).map.min_pairs = 3 + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/5e75dc4322af2cf380488f172a051882a426d197a849163c32c16479ed5ca88e4e83b2bad4dea9167e32ebab6e91f77fef0fa1b23dc3ca92ec28533a0f8ec10d b/modules/sync/bufbuild/protovalidate-testing/cas/5e75dc4322af2cf380488f172a051882a426d197a849163c32c16479ed5ca88e4e83b2bad4dea9167e32ebab6e91f77fef0fa1b23dc3ca92ec28533a0f8ec10d new file mode 100644 index 00000000..a169f893 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/5e75dc4322af2cf380488f172a051882a426d197a849163c32c16479ed5ca88e4e83b2bad4dea9167e32ebab6e91f77fef0fa1b23dc3ca92ec28533a0f8ec10d @@ -0,0 +1,935 @@ +// Copyright 2023-2026 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 FloatNone { + float val = 1; +} +message FloatConst { + float val = 1 [(buf.validate.field).float.const = 1.23]; +} +message FloatIn { + float val = 1 [(buf.validate.field).float = { + in: [ + 4.56, + 7.89 + ] + }]; +} +message FloatNotIn { + float val = 1 [(buf.validate.field).float = { + not_in: [0] + }]; +} +message FloatLT { + float val = 1 [(buf.validate.field).float.lt = 0]; +} +message FloatLTE { + float val = 1 [(buf.validate.field).float.lte = 64]; +} +message FloatGT { + float val = 1 [(buf.validate.field).float.gt = 16]; +} +message FloatGTE { + float val = 1 [(buf.validate.field).float.gte = 8]; +} +message FloatGTLT { + float val = 1 [(buf.validate.field).float = { + gt: 0 + lt: 10 + }]; +} +message FloatExLTGT { + float val = 1 [(buf.validate.field).float = { + lt: 0 + gt: 10 + }]; +} +message FloatGTELTE { + float val = 1 [(buf.validate.field).float = { + gte: 128 + lte: 256 + }]; +} +message FloatExGTELTE { + float val = 1 [(buf.validate.field).float = { + lte: 128 + gte: 256 + }]; +} +message FloatFinite { + float val = 1 [(buf.validate.field).float.finite = true]; +} +message FloatNotFinite { + float val = 1 [(buf.validate.field).float.finite = false]; +} +message FloatIgnore { + float val = 1 [ + (buf.validate.field).float = { + gte: 128 + lte: 256 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} + +message FloatIncorrectType { + float val = 1 [(buf.validate.field).double.gt = 0]; +} + +message FloatExample { + float val = 1 [(buf.validate.field).float.example = 8]; +} + +message DoubleNone { + double val = 1; +} +message DoubleConst { + double val = 1 [(buf.validate.field).double.const = 1.23]; +} +message DoubleIn { + double val = 1 [(buf.validate.field).double = { + in: [ + 4.56, + 7.89 + ] + }]; +} +message DoubleNotIn { + double val = 1 [(buf.validate.field).double = { + not_in: [0] + }]; +} +message DoubleLT { + double val = 1 [(buf.validate.field).double.lt = 0]; +} +message DoubleLTE { + double val = 1 [(buf.validate.field).double.lte = 64]; +} +message DoubleGT { + double val = 1 [(buf.validate.field).double.gt = 16]; +} +message DoubleGTE { + double val = 1 [(buf.validate.field).double.gte = 8]; +} +message DoubleGTLT { + double val = 1 [(buf.validate.field).double = { + gt: 0 + lt: 10 + }]; +} +message DoubleExLTGT { + double val = 1 [(buf.validate.field).double = { + lt: 0 + gt: 10 + }]; +} +message DoubleGTELTE { + double val = 1 [(buf.validate.field).double = { + gte: 128 + lte: 256 + }]; +} +message DoubleExGTELTE { + double val = 1 [(buf.validate.field).double = { + lte: 128 + gte: 256 + }]; +} +message DoubleFinite { + double val = 1 [(buf.validate.field).double.finite = true]; +} +message DoubleNotFinite { + double val = 1 [(buf.validate.field).double.finite = false]; +} +message DoubleIgnore { + double val = 1 [ + (buf.validate.field).double = { + gte: 128 + lte: 256 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} + +message DoubleIncorrectType { + double val = 1 [(buf.validate.field).float.gt = 0]; +} + +message DoubleExample { + double val = 1 [(buf.validate.field).double.example = 0]; +} + +message Int32None { + int32 val = 1; +} +message Int32Const { + int32 val = 1 [(buf.validate.field).int32.const = 1]; +} +message Int32In { + int32 val = 1 [(buf.validate.field).int32 = { + in: [ + 2, + 3 + ] + }]; +} +message Int32NotIn { + int32 val = 1 [(buf.validate.field).int32 = { + not_in: [0] + }]; +} +message Int32LT { + int32 val = 1 [(buf.validate.field).int32.lt = 0]; +} +message Int32LTE { + int32 val = 1 [(buf.validate.field).int32.lte = 64]; +} +message Int32GT { + int32 val = 1 [(buf.validate.field).int32.gt = 16]; +} +message Int32GTE { + int32 val = 1 [(buf.validate.field).int32.gte = 8]; +} +message Int32GTLT { + int32 val = 1 [(buf.validate.field).int32 = { + gt: 0 + lt: 10 + }]; +} +message Int32ExLTGT { + int32 val = 1 [(buf.validate.field).int32 = { + lt: 0 + gt: 10 + }]; +} +message Int32GTELTE { + int32 val = 1 [(buf.validate.field).int32 = { + gte: 128 + lte: 256 + }]; +} +message Int32ExGTELTE { + int32 val = 1 [(buf.validate.field).int32 = { + lte: 128 + gte: 256 + }]; +} +message Int32Ignore { + int32 val = 1 [ + (buf.validate.field).int32 = { + gte: 128 + lte: 256 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} + +message Int32IncorrectType { + int32 val = 1 [(buf.validate.field).float.gt = 0]; +} + +message Int32Example { + int32 val = 1 [(buf.validate.field).int32.example = 10]; +} + +message Int64None { + int64 val = 1; +} +message Int64Const { + int64 val = 1 [(buf.validate.field).int64.const = 1]; +} +message Int64In { + int64 val = 1 [(buf.validate.field).int64 = { + in: [ + 2, + 3 + ] + }]; +} +message Int64NotIn { + int64 val = 1 [(buf.validate.field).int64 = { + not_in: [0] + }]; +} +message Int64LT { + int64 val = 1 [(buf.validate.field).int64.lt = 0]; +} +message Int64LTE { + int64 val = 1 [(buf.validate.field).int64.lte = 64]; +} +message Int64GT { + int64 val = 1 [(buf.validate.field).int64.gt = 16]; +} +message Int64GTE { + int64 val = 1 [(buf.validate.field).int64.gte = 8]; +} +message Int64GTLT { + int64 val = 1 [(buf.validate.field).int64 = { + gt: 0 + lt: 10 + }]; +} +message Int64ExLTGT { + int64 val = 1 [(buf.validate.field).int64 = { + lt: 0 + gt: 10 + }]; +} +message Int64GTELTE { + int64 val = 1 [(buf.validate.field).int64 = { + gte: 128 + lte: 256 + }]; +} +message Int64ExGTELTE { + int64 val = 1 [(buf.validate.field).int64 = { + lte: 128 + gte: 256 + }]; +} +message Int64Ignore { + int64 val = 1 [ + (buf.validate.field).int64 = { + gte: 128 + lte: 256 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} +message Int64BigRules { + // Intentionally choose limits that are outside the range of both signed and unsigned 32-bit integers. + int64 lt_pos = 1 [(buf.validate.field).int64.lt = 5444333222]; + int64 lt_neg = 2 [(buf.validate.field).int64.lt = -5444333222]; + int64 gt_pos = 3 [(buf.validate.field).int64.gt = 5444333222]; + int64 gt_neg = 4 [(buf.validate.field).int64.gt = -5444333222]; + int64 lte_pos = 5 [(buf.validate.field).int64.lte = 5444333222]; + int64 lte_neg = 6 [(buf.validate.field).int64.lte = -5444333222]; + int64 gte_pos = 7 [(buf.validate.field).int64.gte = 5444333222]; + int64 gte_neg = 8 [(buf.validate.field).int64.gte = -5444333222]; + int64 constant_pos = 9 [(buf.validate.field).int64.const = 5444333222]; + int64 constant_neg = 10 [(buf.validate.field).int64.const = -5444333222]; + int64 in = 11 [(buf.validate.field).int64 = { + in: [ + 5444333222, + -5444333222 + ] + }]; + int64 notin = 12 [(buf.validate.field).int64 = { + not_in: [ + 5444333222, + -5444333222 + ] + }]; +} + +message Int64IncorrectType { + int64 val = 1 [(buf.validate.field).float.gt = 0]; +} + +message Int64Example { + int64 val = 1 [(buf.validate.field).int64.example = 10]; +} + +message UInt32None { + uint32 val = 1; +} +message UInt32Const { + uint32 val = 1 [(buf.validate.field).uint32.const = 1]; +} +message UInt32In { + uint32 val = 1 [(buf.validate.field).uint32 = { + in: [ + 2, + 3 + ] + }]; +} +message UInt32NotIn { + uint32 val = 1 [(buf.validate.field).uint32 = { + not_in: [0] + }]; +} +message UInt32LT { + uint32 val = 1 [(buf.validate.field).uint32.lt = 5]; +} +message UInt32LTE { + uint32 val = 1 [(buf.validate.field).uint32.lte = 64]; +} +message UInt32GT { + uint32 val = 1 [(buf.validate.field).uint32.gt = 16]; +} +message UInt32GTE { + uint32 val = 1 [(buf.validate.field).uint32.gte = 8]; +} +message UInt32GTLT { + uint32 val = 1 [(buf.validate.field).uint32 = { + gt: 5 + lt: 10 + }]; +} +message UInt32ExLTGT { + uint32 val = 1 [(buf.validate.field).uint32 = { + lt: 5 + gt: 10 + }]; +} +message UInt32GTELTE { + uint32 val = 1 [(buf.validate.field).uint32 = { + gte: 128 + lte: 256 + }]; +} +message UInt32ExGTELTE { + uint32 val = 1 [(buf.validate.field).uint32 = { + lte: 128 + gte: 256 + }]; +} +message UInt32Ignore { + uint32 val = 1 [ + (buf.validate.field).uint32 = { + gte: 128 + lte: 256 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} + +message UInt32IncorrectType { + uint32 val = 1 [(buf.validate.field).float.gt = 0]; +} + +message UInt32Example { + uint32 val = 1 [(buf.validate.field).uint32.example = 0]; +} + +message UInt64None { + uint64 val = 1; +} +message UInt64Const { + uint64 val = 1 [(buf.validate.field).uint64.const = 1]; +} +message UInt64In { + uint64 val = 1 [(buf.validate.field).uint64 = { + in: [ + 2, + 3 + ] + }]; +} +message UInt64NotIn { + uint64 val = 1 [(buf.validate.field).uint64 = { + not_in: [0] + }]; +} +message UInt64LT { + uint64 val = 1 [(buf.validate.field).uint64.lt = 5]; +} +message UInt64LTE { + uint64 val = 1 [(buf.validate.field).uint64.lte = 64]; +} +message UInt64GT { + uint64 val = 1 [(buf.validate.field).uint64.gt = 16]; +} +message UInt64GTE { + uint64 val = 1 [(buf.validate.field).uint64.gte = 8]; +} +message UInt64GTLT { + uint64 val = 1 [(buf.validate.field).uint64 = { + gt: 5 + lt: 10 + }]; +} +message UInt64ExLTGT { + uint64 val = 1 [(buf.validate.field).uint64 = { + lt: 5 + gt: 10 + }]; +} +message UInt64GTELTE { + uint64 val = 1 [(buf.validate.field).uint64 = { + gte: 128 + lte: 256 + }]; +} +message UInt64ExGTELTE { + uint64 val = 1 [(buf.validate.field).uint64 = { + lte: 128 + gte: 256 + }]; +} +message UInt64Ignore { + uint64 val = 1 [ + (buf.validate.field).uint64 = { + gte: 128 + lte: 256 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} + +message UInt64IncorrectType { + uint64 val = 1 [(buf.validate.field).float.gt = 0]; +} + +message UInt64Example { + uint64 val = 1 [(buf.validate.field).uint64.example = 0]; +} + +message SInt32None { + sint32 val = 1; +} +message SInt32Const { + sint32 val = 1 [(buf.validate.field).sint32.const = 1]; +} +message SInt32In { + sint32 val = 1 [(buf.validate.field).sint32 = { + in: [ + 2, + 3 + ] + }]; +} +message SInt32NotIn { + sint32 val = 1 [(buf.validate.field).sint32 = { + not_in: [0] + }]; +} +message SInt32LT { + sint32 val = 1 [(buf.validate.field).sint32.lt = 0]; +} +message SInt32LTE { + sint32 val = 1 [(buf.validate.field).sint32.lte = 64]; +} +message SInt32GT { + sint32 val = 1 [(buf.validate.field).sint32.gt = 16]; +} +message SInt32GTE { + sint32 val = 1 [(buf.validate.field).sint32.gte = 8]; +} +message SInt32GTLT { + sint32 val = 1 [(buf.validate.field).sint32 = { + gt: 0 + lt: 10 + }]; +} +message SInt32ExLTGT { + sint32 val = 1 [(buf.validate.field).sint32 = { + lt: 0 + gt: 10 + }]; +} +message SInt32GTELTE { + sint32 val = 1 [(buf.validate.field).sint32 = { + gte: 128 + lte: 256 + }]; +} +message SInt32ExGTELTE { + sint32 val = 1 [(buf.validate.field).sint32 = { + lte: 128 + gte: 256 + }]; +} +message SInt32Ignore { + sint32 val = 1 [ + (buf.validate.field).sint32 = { + gte: 128 + lte: 256 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} + +message SInt32IncorrectType { + sint32 val = 1 [(buf.validate.field).float.gt = 0]; +} + +message SInt32Example { + sint32 val = 1 [(buf.validate.field).sint32.example = 0]; +} + +message SInt64None { + sint64 val = 1; +} +message SInt64Const { + sint64 val = 1 [(buf.validate.field).sint64.const = 1]; +} +message SInt64In { + sint64 val = 1 [(buf.validate.field).sint64 = { + in: [ + 2, + 3 + ] + }]; +} +message SInt64NotIn { + sint64 val = 1 [(buf.validate.field).sint64 = { + not_in: [0] + }]; +} +message SInt64LT { + sint64 val = 1 [(buf.validate.field).sint64.lt = 0]; +} +message SInt64LTE { + sint64 val = 1 [(buf.validate.field).sint64.lte = 64]; +} +message SInt64GT { + sint64 val = 1 [(buf.validate.field).sint64.gt = 16]; +} +message SInt64GTE { + sint64 val = 1 [(buf.validate.field).sint64.gte = 8]; +} +message SInt64GTLT { + sint64 val = 1 [(buf.validate.field).sint64 = { + gt: 0 + lt: 10 + }]; +} +message SInt64ExLTGT { + sint64 val = 1 [(buf.validate.field).sint64 = { + lt: 0 + gt: 10 + }]; +} +message SInt64GTELTE { + sint64 val = 1 [(buf.validate.field).sint64 = { + gte: 128 + lte: 256 + }]; +} +message SInt64ExGTELTE { + sint64 val = 1 [(buf.validate.field).sint64 = { + lte: 128 + gte: 256 + }]; +} +message SInt64Ignore { + sint64 val = 1 [ + (buf.validate.field).sint64 = { + gte: 128 + lte: 256 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} +message SInt64IncorrectType { + sint64 val = 1 [(buf.validate.field).float.gt = 0]; +} + +message SInt64Example { + sint64 val = 1 [(buf.validate.field).sint64.example = 0]; +} + +message Fixed32None { + fixed32 val = 1; +} +message Fixed32Const { + fixed32 val = 1 [(buf.validate.field).fixed32.const = 1]; +} +message Fixed32In { + fixed32 val = 1 [(buf.validate.field).fixed32 = { + in: [ + 2, + 3 + ] + }]; +} +message Fixed32NotIn { + fixed32 val = 1 [(buf.validate.field).fixed32 = { + not_in: [0] + }]; +} +message Fixed32LT { + fixed32 val = 1 [(buf.validate.field).fixed32.lt = 5]; +} +message Fixed32LTE { + fixed32 val = 1 [(buf.validate.field).fixed32.lte = 64]; +} +message Fixed32GT { + fixed32 val = 1 [(buf.validate.field).fixed32.gt = 16]; +} +message Fixed32GTE { + fixed32 val = 1 [(buf.validate.field).fixed32.gte = 8]; +} +message Fixed32GTLT { + fixed32 val = 1 [(buf.validate.field).fixed32 = { + gt: 5 + lt: 10 + }]; +} +message Fixed32ExLTGT { + fixed32 val = 1 [(buf.validate.field).fixed32 = { + lt: 5 + gt: 10 + }]; +} +message Fixed32GTELTE { + fixed32 val = 1 [(buf.validate.field).fixed32 = { + gte: 128 + lte: 256 + }]; +} +message Fixed32ExGTELTE { + fixed32 val = 1 [(buf.validate.field).fixed32 = { + lte: 128 + gte: 256 + }]; +} +message Fixed32Ignore { + fixed32 val = 1 [ + (buf.validate.field).fixed32 = { + gte: 128 + lte: 256 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} + +message Fixed32IncorrectType { + fixed32 val = 1 [(buf.validate.field).float.gt = 0]; +} + +message Fixed32Example { + fixed32 val = 1 [(buf.validate.field).fixed32.example = 0]; +} + +message Fixed64None { + fixed64 val = 1; +} +message Fixed64Const { + fixed64 val = 1 [(buf.validate.field).fixed64.const = 1]; +} +message Fixed64In { + fixed64 val = 1 [(buf.validate.field).fixed64 = { + in: [ + 2, + 3 + ] + }]; +} +message Fixed64NotIn { + fixed64 val = 1 [(buf.validate.field).fixed64 = { + not_in: [0] + }]; +} +message Fixed64LT { + fixed64 val = 1 [(buf.validate.field).fixed64.lt = 5]; +} +message Fixed64LTE { + fixed64 val = 1 [(buf.validate.field).fixed64.lte = 64]; +} +message Fixed64GT { + fixed64 val = 1 [(buf.validate.field).fixed64.gt = 16]; +} +message Fixed64GTE { + fixed64 val = 1 [(buf.validate.field).fixed64.gte = 8]; +} +message Fixed64GTLT { + fixed64 val = 1 [(buf.validate.field).fixed64 = { + gt: 5 + lt: 10 + }]; +} +message Fixed64ExLTGT { + fixed64 val = 1 [(buf.validate.field).fixed64 = { + lt: 5 + gt: 10 + }]; +} +message Fixed64GTELTE { + fixed64 val = 1 [(buf.validate.field).fixed64 = { + gte: 128 + lte: 256 + }]; +} +message Fixed64ExGTELTE { + fixed64 val = 1 [(buf.validate.field).fixed64 = { + lte: 128 + gte: 256 + }]; +} +message Fixed64Ignore { + fixed64 val = 1 [ + (buf.validate.field).fixed64 = { + gte: 128 + lte: 256 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} + +message Fixed64IncorrectType { + fixed64 val = 1 [(buf.validate.field).float.gt = 0]; +} + +message Fixed64Example { + fixed64 val = 1 [(buf.validate.field).fixed64.example = 0]; +} + +message SFixed32None { + sfixed32 val = 1; +} +message SFixed32Const { + sfixed32 val = 1 [(buf.validate.field).sfixed32.const = 1]; +} +message SFixed32In { + sfixed32 val = 1 [(buf.validate.field).sfixed32 = { + in: [ + 2, + 3 + ] + }]; +} +message SFixed32NotIn { + sfixed32 val = 1 [(buf.validate.field).sfixed32 = { + not_in: [0] + }]; +} +message SFixed32LT { + sfixed32 val = 1 [(buf.validate.field).sfixed32.lt = 0]; +} +message SFixed32LTE { + sfixed32 val = 1 [(buf.validate.field).sfixed32.lte = 64]; +} +message SFixed32GT { + sfixed32 val = 1 [(buf.validate.field).sfixed32.gt = 16]; +} +message SFixed32GTE { + sfixed32 val = 1 [(buf.validate.field).sfixed32.gte = 8]; +} +message SFixed32GTLT { + sfixed32 val = 1 [(buf.validate.field).sfixed32 = { + gt: 0 + lt: 10 + }]; +} +message SFixed32ExLTGT { + sfixed32 val = 1 [(buf.validate.field).sfixed32 = { + lt: 0 + gt: 10 + }]; +} +message SFixed32GTELTE { + sfixed32 val = 1 [(buf.validate.field).sfixed32 = { + gte: 128 + lte: 256 + }]; +} +message SFixed32ExGTELTE { + sfixed32 val = 1 [(buf.validate.field).sfixed32 = { + lte: 128 + gte: 256 + }]; +} +message SFixed32Ignore { + sfixed32 val = 1 [ + (buf.validate.field).sfixed32 = { + gte: 128 + lte: 256 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} + +message SFixed32IncorrectType { + sfixed32 val = 1 [(buf.validate.field).float.gt = 0]; +} + +message SFixed32Example { + sfixed32 val = 1 [(buf.validate.field).sfixed32.example = 0]; +} + +message SFixed64None { + sfixed64 val = 1; +} +message SFixed64Const { + sfixed64 val = 1 [(buf.validate.field).sfixed64.const = 1]; +} +message SFixed64In { + sfixed64 val = 1 [(buf.validate.field).sfixed64 = { + in: [ + 2, + 3 + ] + }]; +} +message SFixed64NotIn { + sfixed64 val = 1 [(buf.validate.field).sfixed64 = { + not_in: [0] + }]; +} +message SFixed64LT { + sfixed64 val = 1 [(buf.validate.field).sfixed64.lt = 0]; +} +message SFixed64LTE { + sfixed64 val = 1 [(buf.validate.field).sfixed64.lte = 64]; +} +message SFixed64GT { + sfixed64 val = 1 [(buf.validate.field).sfixed64.gt = 16]; +} +message SFixed64GTE { + sfixed64 val = 1 [(buf.validate.field).sfixed64.gte = 8]; +} +message SFixed64GTLT { + sfixed64 val = 1 [(buf.validate.field).sfixed64 = { + gt: 0 + lt: 10 + }]; +} +message SFixed64ExLTGT { + sfixed64 val = 1 [(buf.validate.field).sfixed64 = { + lt: 0 + gt: 10 + }]; +} +message SFixed64GTELTE { + sfixed64 val = 1 [(buf.validate.field).sfixed64 = { + gte: 128 + lte: 256 + }]; +} +message SFixed64ExGTELTE { + sfixed64 val = 1 [(buf.validate.field).sfixed64 = { + lte: 128 + gte: 256 + }]; +} +message SFixed64Ignore { + sfixed64 val = 1 [ + (buf.validate.field).sfixed64 = { + gte: 128 + lte: 256 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} + +message SFixed64IncorrectType { + sfixed64 val = 1 [(buf.validate.field).float.gt = 0]; +} + +message SFixed64Example { + sfixed64 val = 1 [(buf.validate.field).sfixed64.example = 0]; +} + +message Int64LTEOptional { + optional int64 val = 1 [(buf.validate.field).int64.lte = 64]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/63e330e4e445174e10e14c3f1b7a0681210297f24e8dce5786f3763333989c4babcf75ac8e38c8cafe712ca0ddfd37b6de06e4de17e637f5b531789b73899073 b/modules/sync/bufbuild/protovalidate-testing/cas/63e330e4e445174e10e14c3f1b7a0681210297f24e8dce5786f3763333989c4babcf75ac8e38c8cafe712ca0ddfd37b6de06e4de17e637f5b531789b73899073 new file mode 100644 index 00000000..af2846ef --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/63e330e4e445174e10e14c3f1b7a0681210297f24e8dce5786f3763333989c4babcf75ac8e38c8cafe712ca0ddfd37b6de06e4de17e637f5b531789b73899073 @@ -0,0 +1,51 @@ +// Copyright 2023-2026 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.harness; + +import "buf/validate/validate.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/descriptor.proto"; + +// TestConformanceRequest is the request for Conformance Tests. +// The FileDescriptorSet is the FileDescriptorSet to test against. +// The cases map is a map of case name to the Any message that represents the case. +message TestConformanceRequest { + google.protobuf.FileDescriptorSet fdset = 2; + map cases = 3; +} + +// TestConformanceResponse is the response for Conformance Tests. +// The results map is a map of case name to the TestResult. +message TestConformanceResponse { + map results = 1; +} + +// TestResult is the result of a single test. Only one of the fields will be set. +message TestResult { + oneof result { + // success is true if the test succeeded. + bool success = 1; + // validation_error is the error if the test failed due to validation errors. + Violations validation_error = 2; + // compilation_error is the error if the test failed due to compilation errors. + string compilation_error = 3; + // runtime_error is the error if the test failed due to runtime errors. + string runtime_error = 4; + // unexpected_error is any other error that may have occurred. + string unexpected_error = 5; + } +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/6a1a59a042a08516a5a7620714148e94fa9fff0dfbd8b71af99c15cfeb9791c7bc7a8bd6573a02ba9a21124f836d80845b0623e5ddf3fae2ea61dbdd1434f4d3 b/modules/sync/bufbuild/protovalidate-testing/cas/6a1a59a042a08516a5a7620714148e94fa9fff0dfbd8b71af99c15cfeb9791c7bc7a8bd6573a02ba9a21124f836d80845b0623e5ddf3fae2ea61dbdd1434f4d3 new file mode 100644 index 00000000..97fc2c34 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/6a1a59a042a08516a5a7620714148e94fa9fff0dfbd8b71af99c15cfeb9791c7bc7a8bd6573a02ba9a21124f836d80845b0623e5ddf3fae2ea61dbdd1434f4d3 @@ -0,0 +1,233 @@ +// Copyright 2023-2026 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 Proto3ScalarOptionalIgnoreUnspecified { + optional int32 val = 1 [(buf.validate.field).int32.gt = 0]; +} + +message Proto3ScalarOptionalIgnoreEmpty { + optional int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +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]; +} + +message Proto3ScalarIgnoreEmpty { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +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" + message: "foobar" + expression: "this.val == 'foo'" + }]; + message Msg { + optional string val = 1; + } +} + +message Proto3MessageOptionalIgnoreEmpty { + optional Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).cel = { + id: "proto3.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + optional string val = 1; + } +} + +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" + message: "foobar" + expression: "this.val == 'foo'" + }]; + message Msg { + optional string val = 1; + } +} + +message Proto3MessageIgnoreEmpty { + Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_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]; + } +} + +message Proto3OneofIgnoreEmpty { + oneof o { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; + } +} + +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]; +} + +message Proto3RepeatedIgnoreEmpty { + repeated int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message Proto3RepeatedIgnoreAlways { + repeated int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message Proto3MapIgnoreUnspecified { + map val = 1 [(buf.validate.field).map.min_pairs = 3]; +} + +message Proto3MapIgnoreEmpty { + map val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).map.min_pairs = 3 + ]; +} + +message Proto3MapIgnoreAlways { + map 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]; +} + +message Proto3RepeatedItemIgnoreEmpty { + repeated int32 val = 1 [ + (buf.validate.field).repeated.items.ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).repeated.items.int32.gt = 0 + ]; +} + +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 val = 1 [(buf.validate.field).map.keys.int32.gt = 0]; +} + +message Proto3MapKeyIgnoreEmpty { + map val = 1 [ + (buf.validate.field).map.keys.ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).map.keys.int32.gt = 0 + ]; +} + +message Proto3MapKeyIgnoreAlways { + map val = 1 [ + (buf.validate.field).map.keys.ignore = IGNORE_ALWAYS, + (buf.validate.field).map.keys.int32.gt = 0 + ]; +} + +message Proto3MapValueIgnoreUnspecified { + map val = 1 [(buf.validate.field).map.values.int32.gt = 0]; +} + +message Proto3MapValueIgnoreEmpty { + map val = 1 [ + (buf.validate.field).map.values.ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).map.values.int32.gt = 0 + ]; +} + +message Proto3MapValueIgnoreAlways { + map val = 1 [ + (buf.validate.field).map.values.ignore = IGNORE_ALWAYS, + (buf.validate.field).map.values.int32.gt = 0 + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/7282dfa1b32ce707d079e04c4c1dae8df7ad70c559a4e1ef6ccde76d45300cb5ba18a92f04d09eaa54365cf589f914c76677d98efec4a9836c192d63adf73fad b/modules/sync/bufbuild/protovalidate-testing/cas/7282dfa1b32ce707d079e04c4c1dae8df7ad70c559a4e1ef6ccde76d45300cb5ba18a92f04d09eaa54365cf589f914c76677d98efec4a9836c192d63adf73fad new file mode 100644 index 00000000..57a09f0a --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/7282dfa1b32ce707d079e04c4c1dae8df7ad70c559a4e1ef6ccde76d45300cb5ba18a92f04d09eaa54365cf589f914c76677d98efec4a9836c192d63adf73fad @@ -0,0 +1,76 @@ +// Copyright 2023-2026 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"; +import "google/protobuf/wrappers.proto"; + +message WrapperNone { + google.protobuf.Int32Value val = 1; +} + +message WrapperFloat { + google.protobuf.FloatValue val = 1 [(buf.validate.field).float.gt = 0]; +} +message WrapperDouble { + google.protobuf.DoubleValue val = 1 [(buf.validate.field).double.gt = 0]; +} +message WrapperInt64 { + google.protobuf.Int64Value val = 1 [(buf.validate.field).int64.gt = 0]; +} +message WrapperInt32 { + google.protobuf.Int32Value val = 1 [(buf.validate.field).int32.gt = 0]; +} +message WrapperUInt64 { + google.protobuf.UInt64Value val = 1 [(buf.validate.field).uint64.gt = 0]; +} +message WrapperUInt32 { + google.protobuf.UInt32Value val = 1 [(buf.validate.field).uint32.gt = 0]; +} +message WrapperBool { + google.protobuf.BoolValue val = 1 [(buf.validate.field).bool.const = true]; +} +message WrapperString { + google.protobuf.StringValue val = 1 [(buf.validate.field).string.suffix = "bar"]; +} +message WrapperBytes { + google.protobuf.BytesValue val = 1 [(buf.validate.field).bytes.min_len = 3]; +} +message WrapperRequiredString { + google.protobuf.StringValue val = 1 [ + (buf.validate.field).string.const = "bar", + (buf.validate.field).required = true + ]; +} +message WrapperRequiredEmptyString { + google.protobuf.StringValue val = 1 [ + (buf.validate.field).string.const = "", + (buf.validate.field).required = true + ]; +} +message WrapperOptionalUuidString { + google.protobuf.StringValue val = 1 [ + (buf.validate.field).string.uuid = true, + (buf.validate.field).required = false + ]; +} +message WrapperRequiredFloat { + google.protobuf.FloatValue val = 1 [ + (buf.validate.field).float.gt = 0, + (buf.validate.field).required = true + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/75ceb0ab3ae7d9a8664b5a65d2f7c2fb9ceb48d351b02cf05af91de1a25fab9b873b8cc388b4117cef064c7c12ad573d55bfa741bcdf868213212c945a11822f b/modules/sync/bufbuild/protovalidate-testing/cas/75ceb0ab3ae7d9a8664b5a65d2f7c2fb9ceb48d351b02cf05af91de1a25fab9b873b8cc388b4117cef064c7c12ad573d55bfa741bcdf868213212c945a11822f new file mode 100644 index 00000000..dc61c29b --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/75ceb0ab3ae7d9a8664b5a65d2f7c2fb9ceb48d351b02cf05af91de1a25fab9b873b8cc388b4117cef064c7c12ad573d55bfa741bcdf868213212c945a11822f @@ -0,0 +1,26 @@ +// Copyright 2023-2026 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. + +edition = "2023"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message GroupDelimited { + Value value = 1 [features.message_encoding = DELIMITED]; + message Value { + bool x = 1 [(buf.validate.field).bool.const = true]; + } +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/7969e46bcc89b0c6ed3f99d5c66e107521a24b0ad7716949d44b4bd64e1efab0a01955b7a3061b82eccaad514b18a4c48d94daf0d8273fa5505e19b85829f198 b/modules/sync/bufbuild/protovalidate-testing/cas/7969e46bcc89b0c6ed3f99d5c66e107521a24b0ad7716949d44b4bd64e1efab0a01955b7a3061b82eccaad514b18a4c48d94daf0d8273fa5505e19b85829f198 new file mode 100644 index 00000000..e97d51e2 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/7969e46bcc89b0c6ed3f99d5c66e107521a24b0ad7716949d44b4bd64e1efab0a01955b7a3061b82eccaad514b18a4c48d94daf0d8273fa5505e19b85829f198 @@ -0,0 +1,203 @@ +// Copyright 2023-2026 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/conformance/cases/other_package/embed.proto"; +import "buf/validate/validate.proto"; + +message TestMsg { + string const = 1 [(buf.validate.field).string.const = "foo"]; + TestMsg nested = 2; +} + +message MessageNone { + NoneMsg val = 1; + message NoneMsg {} +} + +message Message { + TestMsg val = 1; +} +message MessageCrossPackage { + other_package.Embed val = 1; +} +message MessageSkip { + TestMsg val = 1 [(buf.validate.field).ignore = IGNORE_ALWAYS]; +} +message MessageRequired { + TestMsg val = 1 [(buf.validate.field).required = true]; +} +message MessageRequiredButOptional { + optional TestMsg val = 1 [(buf.validate.field).required = true]; +} + +message MessageRequiredOneof { + oneof one { + option (buf.validate.oneof).required = true; + TestMsg val = 1 [(buf.validate.field).required = true]; + } +} + +message MessageWith3dInside {} + +message MessageOneofSingleField { + option (buf.validate.message).oneof = { + fields: ["str_field"] + }; + string str_field = 1; + bool bool_field = 2; +} + +message MessageOneofSingleFieldRequired { + option (buf.validate.message).oneof = { + fields: ["str_field"] + required: true + }; + string str_field = 1; + bool bool_field = 2; +} + +message MessageOneofMultipleFields { + option (buf.validate.message).oneof = { + fields: [ + "str_field", + "bool_field" + ] + }; + string str_field = 1; + bool bool_field = 2; +} + +message MessageOneofMultipleFieldsRequired { + option (buf.validate.message).oneof = { + fields: [ + "str_field", + "bool_field" + ] + required: true + }; + string str_field = 1; + bool bool_field = 2; +} + +message MessageOneofMultipleSharedFields { + option (buf.validate.message).oneof = { + fields: [ + "str_field", + "bool_field" + ] + required: true + }; + option (buf.validate.message).oneof = { + fields: [ + "str_field", + "int_field" + ] + required: true + }; + string str_field = 1; + bool bool_field = 2; + int32 int_field = 3; +} + +message MessageOneofUnknownFieldName { + option (buf.validate.message).oneof = { + fields: ["xxx"] + }; + string str_field = 1; +} + +message MessageOneofDuplicateField { + option (buf.validate.message).oneof = { + fields: [ + "str_field", + "bool_field", + "str_field" + ] + }; + string str_field = 1; + bool bool_field = 2; +} + +message MessageOneofZeroFields { + option (buf.validate.message).oneof = { + fields: [] + }; + string str_field = 1; + bool bool_field = 2; +} + +message MessageOneofUnsatisfiable { + bool a = 1; + bool b = 2; + bool c = 3; + option (buf.validate.message).oneof = { + fields: [ + "a", + "b" + ] + required: true + }; + option (buf.validate.message).oneof = { + fields: [ + "b", + "c" + ] + required: true + }; + option (buf.validate.message).oneof = { + fields: [ + "a", + "c" + ] + required: true + }; +} + +message MessageOneofIgnoreUnpopulated { + option (buf.validate.message).oneof = { + fields: [ + "str_field", + "bool_field" + ] + }; + string str_field = 1; + bool bool_field = 2 [(buf.validate.field).bool.const = true]; +} + +message MessageOneofIgnoreUnpopulatedRequired { + option (buf.validate.message).oneof = { + fields: [ + "str_field", + "bool_field" + ] + required: true + }; + string str_field = 1; + bool bool_field = 2 [(buf.validate.field).bool.const = true]; +} + +message MessageOneofIgnoreOverride { + option (buf.validate.message).oneof = { + fields: [ + "msg_field", + "bool_field" + ] + }; + TestMsg msg_field = 1 [(buf.validate.field).ignore = IGNORE_ALWAYS]; + bool bool_field = 2; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/7bb300d336cfa0156b468667169b00a50beca4e42a02cfa466aaa35460eddae7c824ff7edaa670443dd97c094c01bec61f4b742b571b4d970aec933998a5845e b/modules/sync/bufbuild/protovalidate-testing/cas/7bb300d336cfa0156b468667169b00a50beca4e42a02cfa466aaa35460eddae7c824ff7edaa670443dd97c094c01bec61f4b742b571b4d970aec933998a5845e new file mode 100644 index 00000000..7f052872 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/7bb300d336cfa0156b468667169b00a50beca4e42a02cfa466aaa35460eddae7c824ff7edaa670443dd97c094c01bec61f4b742b571b4d970aec933998a5845e @@ -0,0 +1,73 @@ +// Copyright 2023-2026 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 IsHostname { + string val = 1; + option (buf.validate.message).cel = { + id: "library.is_hostname" + expression: "this.val.isHostname()" + }; +} +message IsHostAndPort { + string val = 1; + bool port_required = 2; + option (buf.validate.message).cel = { + id: "library.is_host_and_port" + expression: "this.val.isHostAndPort(this.port_required)" + }; +} +message IsIpPrefix { + string val = 1; + optional int32 version = 2; + optional bool strict = 3; + option (buf.validate.message).cel = { + id: "library.is_ip_prefix" + expression: "has(this.version) && has(this.strict) ? this.val.isIpPrefix(this.version, this.strict) : has(this.version) ? this.val.isIpPrefix(this.version) : has(this.strict) ? this.val.isIpPrefix(this.strict) : this.val.isIpPrefix()" + }; +} +message IsIp { + string val = 1; + optional int32 version = 2; + option (buf.validate.message).cel = { + id: "library.is_ip" + expression: "has(this.version) ? this.val.isIp(this.version) : this.val.isIp()" + }; +} +message IsEmail { + string val = 1; + option (buf.validate.message).cel = { + id: "library.is_email" + expression: "this.val.isEmail()" + }; +} +message IsUri { + string val = 1; + option (buf.validate.message).cel = { + id: "library.is_uri" + expression: "this.val.isUri()" + }; +} +message IsUriRef { + string val = 1; + option (buf.validate.message).cel = { + id: "library.is_uri_ref" + expression: "this.val.isUriRef()" + }; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/9269552129342bb2bc922f89dda22c31a3e9532154d1fca27efb20f17a7ad43a0c225a0ba7596b2531f46cdd06b1bf4dfc825dbfc97a6fa7345d2a1e19280cd3 b/modules/sync/bufbuild/protovalidate-testing/cas/9269552129342bb2bc922f89dda22c31a3e9532154d1fca27efb20f17a7ad43a0c225a0ba7596b2531f46cdd06b1bf4dfc825dbfc97a6fa7345d2a1e19280cd3 new file mode 100644 index 00000000..fed9174e --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/9269552129342bb2bc922f89dda22c31a3e9532154d1fca27efb20f17a7ad43a0c225a0ba7596b2531f46cdd06b1bf4dfc825dbfc97a6fa7345d2a1e19280cd3 @@ -0,0 +1,150 @@ +// Copyright 2023-2026 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. + +edition = "2023"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message IgnoreEmptyEditionsScalarExplicitPresence { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyEditionsScalarExplicitPresenceWithDefault { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0, + default = 42 + ]; +} + +message IgnoreEmptyEditionsScalarImplicitPresence { + int32 val = 1 [ + features.field_presence = IMPLICIT, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyEditionsScalarLegacyRequired { + int32 val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyEditionsScalarLegacyRequiredWithDefault { + int32 val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0, + default = 42 + ]; +} + +message IgnoreEmptyEditionsMessageExplicitPresence { + Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).cel = { + id: "ignore_empty.editions.message" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message IgnoreEmptyEditionsMessageExplicitPresenceDelimited { + Msg val = 1 [ + features.message_encoding = DELIMITED, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).cel = { + id: "ignore_empty.editions.message" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message IgnoreEmptyEditionsMessageLegacyRequired { + Msg val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).cel = { + id: "ignore_empty.editions.message" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message IgnoreEmptyEditionsMessageLegacyRequiredDelimited { + Msg val = 1 [ + features.message_encoding = DELIMITED, + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).cel = { + id: "ignore_empty.editions.message" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message IgnoreEmptyEditionsOneof { + oneof o { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; + } +} + +message IgnoreEmptyEditionsRepeated { + repeated int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message IgnoreEmptyEditionsRepeatedExpanded { + repeated int32 val = 1 [ + features.repeated_field_encoding = EXPANDED, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message IgnoreEmptyEditionsMap { + map val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).map.min_pairs = 3 + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/99047ed1eddac0b6ab7063ceb2a52b6b429da9d42f3ceddd431f59d23675c85ba1bacb1f8f8e49397833c961e580720055b3c86af5bba972e664da7f6d91e86f b/modules/sync/bufbuild/protovalidate-testing/cas/99047ed1eddac0b6ab7063ceb2a52b6b429da9d42f3ceddd431f59d23675c85ba1bacb1f8f8e49397833c961e580720055b3c86af5bba972e664da7f6d91e86f new file mode 100644 index 00000000..26ce95aa --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/99047ed1eddac0b6ab7063ceb2a52b6b429da9d42f3ceddd431f59d23675c85ba1bacb1f8f8e49397833c961e580720055b3c86af5bba972e664da7f6d91e86f @@ -0,0 +1,32 @@ +// Copyright 2023-2026 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 BoolNone { + bool val = 1; +} +message BoolConstTrue { + bool val = 1 [(buf.validate.field).bool.const = true]; +} +message BoolConstFalse { + bool val = 1 [(buf.validate.field).bool.const = false]; +} +message BoolExample { + bool val = 1 [(buf.validate.field).bool.example = true]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/9c90cb9d680419cd0415b76d45deec686d98616083f8abee38bdda797ea332a59b4af37bcb642de0796b2ac406476b28603b49e481a839a024958515adec1e7b b/modules/sync/bufbuild/protovalidate-testing/cas/9c90cb9d680419cd0415b76d45deec686d98616083f8abee38bdda797ea332a59b4af37bcb642de0796b2ac406476b28603b49e481a839a024958515adec1e7b new file mode 100644 index 00000000..7b26930a --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/9c90cb9d680419cd0415b76d45deec686d98616083f8abee38bdda797ea332a59b4af37bcb642de0796b2ac406476b28603b49e481a839a024958515adec1e7b @@ -0,0 +1,36 @@ +// Copyright 2023-2026 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.other_package; + +import "buf/validate/validate.proto"; + +// Validate message embedding across packages. +message Embed { + message DoubleEmbed { + enum DoubleEnumerated { + DOUBLE_ENUMERATED_UNSPECIFIED = 0; + DOUBLE_ENUMERATED_VALUE = 1; + } + } + + int64 val = 1 [(buf.validate.field).int64.gt = 0]; + + enum Enumerated { + ENUMERATED_UNSPECIFIED = 0; + ENUMERATED_VALUE = 1; + } +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/9f2a9fed6dfb460fff19f964b6c1f529118793f094e00c07b04501e5553ed331485076570bdb278b0a83420d8d296d0995922f83cb441f1aa9fceabc7302b494 b/modules/sync/bufbuild/protovalidate-testing/cas/9f2a9fed6dfb460fff19f964b6c1f529118793f094e00c07b04501e5553ed331485076570bdb278b0a83420d8d296d0995922f83cb441f1aa9fceabc7302b494 new file mode 100644 index 00000000..5e53bee4 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/9f2a9fed6dfb460fff19f964b6c1f529118793f094e00c07b04501e5553ed331485076570bdb278b0a83420d8d296d0995922f83cb441f1aa9fceabc7302b494 @@ -0,0 +1,171 @@ +// Copyright 2023-2026 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. + +edition = "2023"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message RequiredEditionsScalarExplicitPresence { + string val = 1 [(buf.validate.field).required = true]; +} +message RequiredEditionsScalarExplicitPresenceIgnoreAlways { + string val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} + +message RequiredEditionsScalarExplicitPresenceDefault { + string val = 1 [ + (buf.validate.field).required = true, + default = "foo" + ]; +} +message RequiredEditionsScalarExplicitPresenceDefaultIgnoreAlways { + string val = 1 [ + (buf.validate.field).required = true, + default = "foo", + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} + +message RequiredEditionsScalarImplicitPresence { + string val = 1 [ + features.field_presence = IMPLICIT, + (buf.validate.field).required = true + ]; +} +message RequiredEditionsScalarImplicitPresenceIgnoreAlways { + string val = 1 [ + features.field_presence = IMPLICIT, + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} + +message RequiredEditionsScalarLegacyRequired { + string val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).required = true + ]; +} + +message RequiredEditionsMessageExplicitPresence { + Msg val = 1 [(buf.validate.field).required = true]; + message Msg { + string val = 1; + } +} +message RequiredEditionsMessageExplicitPresenceIgnoreAlways { + Msg val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; + message Msg { + string val = 1; + } +} + +message RequiredEditionsMessageExplicitPresenceDelimited { + Msg val = 1 [ + features.message_encoding = DELIMITED, + (buf.validate.field).required = true + ]; + message Msg { + string val = 1; + } +} +message RequiredEditionsMessageExplicitPresenceDelimitedIgnoreAlways { + Msg val = 1 [ + features.message_encoding = DELIMITED, + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; + message Msg { + string val = 1; + } +} + +message RequiredEditionsMessageLegacyRequired { + Msg val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).required = true + ]; + message Msg { + string val = 1; + } +} + +message RequiredEditionsMessageLegacyRequiredDelimited { + Msg val = 1 [ + features.message_encoding = DELIMITED, + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).required = true + ]; + message Msg { + string val = 1; + } +} + +message RequiredEditionsOneof { + oneof val { + string a = 1 [(buf.validate.field).required = true]; + string b = 2; + } +} +message RequiredEditionsOneofIgnoreAlways { + oneof val { + string a = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; + string b = 2; + } +} + +message RequiredEditionsRepeated { + repeated string val = 1 [(buf.validate.field).required = true]; +} +message RequiredEditionsRepeatedIgnoreAlways { + repeated string val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} + +message RequiredEditionsRepeatedExpanded { + repeated string val = 1 [ + features.repeated_field_encoding = EXPANDED, + (buf.validate.field).required = true + ]; +} +message RequiredEditionsRepeatedExpandedIgnoreAlways { + repeated string val = 1 [ + features.repeated_field_encoding = EXPANDED, + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} + +message RequiredEditionsMap { + map val = 1 [(buf.validate.field).required = true]; +} +message RequiredEditionsMapIgnoreAlways { + map val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/a82ceea3b542e392624be12293788d4fa1bf88e487e567f3ace688fd55b4b73dd11104e91917f9c1866b68b6c611d5f2c9505e73e93e5e2903e7a2aba26b3cb5 b/modules/sync/bufbuild/protovalidate-testing/cas/a82ceea3b542e392624be12293788d4fa1bf88e487e567f3ace688fd55b4b73dd11104e91917f9c1866b68b6c611d5f2c9505e73e93e5e2903e7a2aba26b3cb5 new file mode 100644 index 00000000..850a539b --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/a82ceea3b542e392624be12293788d4fa1bf88e487e567f3ace688fd55b4b73dd11104e91917f9c1866b68b6c611d5f2c9505e73e93e5e2903e7a2aba26b3cb5 @@ -0,0 +1,99 @@ +// Copyright 2023-2026 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 RequiredProto2ScalarOptionalIgnoreAlways { + optional string val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} + +message RequiredProto2ScalarOptionalDefault { + optional string val = 1 [ + (buf.validate.field).required = true, + default = "foo" + ]; +} +message RequiredProto2ScalarOptionalDefaultIgnoreAlways { + optional string val = 1 [ + (buf.validate.field).required = true, + default = "foo", + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} + +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 RequiredProto2MessageIgnoreAlways { + optional Msg val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; + message Msg { + optional string val = 1; + } +} + +message RequiredProto2Oneof { + oneof val { + string a = 1 [(buf.validate.field).required = true]; + string b = 2; + } +} +message RequiredProto2OneofIgnoreAlways { + oneof val { + string a = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; + string b = 2; + } +} + +message RequiredProto2Repeated { + repeated string val = 1 [(buf.validate.field).required = true]; +} +message RequiredProto2RepeatedIgnoreAlways { + repeated string val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} + +message RequiredProto2Map { + map val = 1 [(buf.validate.field).required = true]; +} +message RequiredProto2MapIgnoreAlways { + map val = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).ignore = IGNORE_ALWAYS + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/b378199efb09514bf23931c73626f091b2512e4c3fa3e4d8fb0682bfe8bbd5570a9ac20ca6499fd31b173ba73bb6d3bec6442c0fdd9c91fa402fa45e7aff4c10 b/modules/sync/bufbuild/protovalidate-testing/cas/b378199efb09514bf23931c73626f091b2512e4c3fa3e4d8fb0682bfe8bbd5570a9ac20ca6499fd31b173ba73bb6d3bec6442c0fdd9c91fa402fa45e7aff4c10 new file mode 100644 index 00000000..2c5355c9 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/b378199efb09514bf23931c73626f091b2512e4c3fa3e4d8fb0682bfe8bbd5570a9ac20ca6499fd31b173ba73bb6d3bec6442c0fdd9c91fa402fa45e7aff4c10 @@ -0,0 +1,495 @@ +// Copyright 2023-2026 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. + +edition = "2023"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message EditionsScalarExplicitPresenceIgnoreUnspecified { + int32 val = 1 [(buf.validate.field).int32.gt = 0]; +} + +message EditionsScalarExplicitPresenceIgnoreUnspecifiedWithDefault { + int32 val = 1 [ + (buf.validate.field).int32.gt = 0, + default = -42 + ]; +} + +message EditionsScalarExplicitPresenceIgnoreEmpty { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +message EditionsScalarExplicitPresenceIgnoreEmptyWithDefault { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0, + default = -42 + ]; +} + +message EditionsScalarExplicitPresenceIgnoreAlways { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).int32.gt = 0 + ]; +} + +message EditionsScalarExplicitPresenceIgnoreAlwaysWithDefault { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).int32.gt = 0, + default = -42 + ]; +} + +message EditionsScalarImplicitPresenceIgnoreUnspecified { + int32 val = 1 [ + features.field_presence = IMPLICIT, + (buf.validate.field).int32.gt = 0 + ]; +} + +message EditionsScalarImplicitPresenceIgnoreEmpty { + int32 val = 1 [ + features.field_presence = IMPLICIT, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +message EditionsScalarImplicitPresenceIgnoreAlways { + int32 val = 1 [ + features.field_presence = IMPLICIT, + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).int32.gt = 0 + ]; +} + +message EditionsScalarLegacyRequiredIgnoreUnspecified { + int32 val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).int32.gt = 0 + ]; +} + +message EditionsScalarLegacyRequiredIgnoreUnspecifiedWithDefault { + int32 val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).int32.gt = 0, + default = -42 + ]; +} + +message EditionsScalarLegacyRequiredIgnoreEmpty { + int32 val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; +} + +message EditionsScalarLegacyRequiredIgnoreEmptyWithDefault { + int32 val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0, + default = -42 + ]; +} + +message EditionsScalarLegacyRequiredIgnoreAlways { + int32 val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).int32.gt = 0 + ]; +} + +message EditionsScalarLegacyRequiredIgnoreAlwaysWithDefault { + int32 val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).int32.gt = 0, + default = -42 + ]; +} + +message EditionsMessageExplicitPresenceIgnoreUnspecified { + Msg val = 1 [(buf.validate.field).cel = { + id: "proto.editions.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + }]; + message Msg { + string val = 1; + } +} + +message EditionsMessageExplicitPresenceDelimitedIgnoreUnspecified { + Msg val = 1 [ + features.message_encoding = DELIMITED, + (buf.validate.field).cel = { + id: "proto.editions.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message EditionsMessageExplicitPresenceIgnoreEmpty { + Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).cel = { + id: "proto.editions.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message EditionsMessageExplicitPresenceDelimitedIgnoreEmpty { + Msg val = 1 [ + features.message_encoding = DELIMITED, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).cel = { + id: "proto.editions.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message EditionsMessageExplicitPresenceIgnoreAlways { + Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).cel = { + id: "proto.editions.message.ignore.always" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message EditionsMessageExplicitPresenceDelimitedIgnoreAlways { + Msg val = 1 [ + features.message_encoding = DELIMITED, + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).cel = { + id: "proto.editions.message.ignore.always" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message EditionsMessageLegacyRequiredIgnoreUnspecified { + Msg val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).cel = { + id: "proto.editions.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message EditionsMessageLegacyRequiredDelimitedIgnoreUnspecified { + Msg val = 1 [ + features.message_encoding = DELIMITED, + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).cel = { + id: "proto.editions.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message EditionsMessageLegacyRequiredIgnoreEmpty { + Msg val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).cel = { + id: "proto.editions.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message EditionsMessageLegacyRequiredDelimitedIgnoreEmpty { + Msg val = 1 [ + features.message_encoding = DELIMITED, + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).cel = { + id: "proto.editions.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message EditionsMessageLegacyRequiredIgnoreAlways { + Msg val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).cel = { + id: "proto.editions.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message EditionsMessageLegacyRequiredDelimitedIgnoreAlways { + Msg val = 1 [ + features.message_encoding = DELIMITED, + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).cel = { + id: "proto.editions.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + string val = 1; + } +} + +message EditionsOneofIgnoreUnspecified { + oneof o { + int32 val = 1 [(buf.validate.field).int32.gt = 0]; + } +} + +message EditionsOneofIgnoreUnspecifiedWithDefault { + oneof o { + int32 val = 1 [ + (buf.validate.field).int32.gt = 0, + default = -42 + ]; + } +} + +message EditionsOneofIgnoreEmpty { + oneof o { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0 + ]; + } +} + +message EditionsOneofIgnoreEmptyWithDefault { + oneof o { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).int32.gt = 0, + default = -42 + ]; + } +} + +message EditionsOneofIgnoreAlways { + oneof o { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).int32.gt = 0 + ]; + } +} + +message EditionsOneofIgnoreAlwaysWithDefault { + oneof o { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).int32.gt = 0, + default = -42 + ]; + } +} + +message EditionsRepeatedIgnoreUnspecified { + repeated int32 val = 1 [(buf.validate.field).repeated.min_items = 3]; +} + +message EditionsRepeatedExpandedIgnoreUnspecified { + repeated int32 val = 1 [ + features.repeated_field_encoding = EXPANDED, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message EditionsRepeatedIgnoreEmpty { + repeated int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message EditionsRepeatedExpandedIgnoreEmpty { + repeated int32 val = 1 [ + features.repeated_field_encoding = EXPANDED, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message EditionsRepeatedIgnoreAlways { + repeated int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message EditionsRepeatedExpandedIgnoreAlways { + repeated int32 val = 1 [ + features.repeated_field_encoding = EXPANDED, + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message EditionsMapIgnoreUnspecified { + map val = 1 [(buf.validate.field).map.min_pairs = 3]; +} + +message EditionsMapIgnoreEmpty { + map val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).map.min_pairs = 3 + ]; +} + +message EditionsMapIgnoreAlways { + map val = 1 [ + (buf.validate.field).ignore = IGNORE_ALWAYS, + (buf.validate.field).map.min_pairs = 3 + ]; +} + +message EditionsRepeatedItemIgnoreUnspecified { + repeated int32 val = 1 [(buf.validate.field).repeated.items.int32.gt = 0]; +} + +message EditionsRepeatedExpandedItemIgnoreUnspecified { + repeated int32 val = 1 [ + features.repeated_field_encoding = EXPANDED, + (buf.validate.field).repeated.items.int32.gt = 0 + ]; +} + +message EditionsRepeatedItemIgnoreEmpty { + repeated int32 val = 1 [ + (buf.validate.field).repeated.items.ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).repeated.items.int32.gt = 0 + ]; +} + +message EditionsRepeatedExpandedItemIgnoreEmpty { + repeated int32 val = 1 [ + features.repeated_field_encoding = EXPANDED, + (buf.validate.field).repeated.items.ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).repeated.items.int32.gt = 0 + ]; +} + +message EditionsRepeatedItemIgnoreAlways { + repeated int32 val = 1 [ + (buf.validate.field).repeated.items.ignore = IGNORE_ALWAYS, + (buf.validate.field).repeated.items.int32.gt = 0 + ]; +} + +message EditionsRepeatedExpandedItemIgnoreAlways { + repeated int32 val = 1 [ + features.repeated_field_encoding = EXPANDED, + (buf.validate.field).repeated.items.ignore = IGNORE_ALWAYS, + (buf.validate.field).repeated.items.int32.gt = 0 + ]; +} + +message EditionsMapKeyIgnoreUnspecified { + map val = 1 [(buf.validate.field).map.keys.int32.gt = 0]; +} + +message EditionsMapKeyIgnoreEmpty { + map val = 1 [ + (buf.validate.field).map.keys.ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).map.keys.int32.gt = 0 + ]; +} + +message EditionsMapKeyIgnoreAlways { + map val = 1 [ + (buf.validate.field).map.keys.ignore = IGNORE_ALWAYS, + (buf.validate.field).map.keys.int32.gt = 0 + ]; +} + +message EditionsMapValueIgnoreUnspecified { + map val = 1 [(buf.validate.field).map.values.int32.gt = 0]; +} + +message EditionsMapValueIgnoreEmpty { + map val = 1 [ + (buf.validate.field).map.values.ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).map.values.int32.gt = 0 + ]; +} + +message EditionsMapValueIgnoreAlways { + map val = 1 [ + (buf.validate.field).map.values.ignore = IGNORE_ALWAYS, + (buf.validate.field).map.values.int32.gt = 0 + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/b7fcdf6e69bf02bd3fbe0e9412f1e6b5aa36c0a1af20a82280b1bbecea8d5d64493baaae8d6c12ddbaafb77651c7b2119fc9411eb4883dc3ea2c2470b8bc3ee4 b/modules/sync/bufbuild/protovalidate-testing/cas/b7fcdf6e69bf02bd3fbe0e9412f1e6b5aa36c0a1af20a82280b1bbecea8d5d64493baaae8d6c12ddbaafb77651c7b2119fc9411eb4883dc3ea2c2470b8bc3ee4 new file mode 100644 index 00000000..1283a7bf --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/b7fcdf6e69bf02bd3fbe0e9412f1e6b5aa36c0a1af20a82280b1bbecea8d5d64493baaae8d6c12ddbaafb77651c7b2119fc9411eb4883dc3ea2c2470b8bc3ee4 @@ -0,0 +1,261 @@ +// Copyright 2023-2026 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 StringNone { + string val = 1; +} +message StringConst { + string val = 1 [(buf.validate.field).string.const = "foo"]; +} +message StringIn { + string val = 1 [(buf.validate.field).string = { + in: [ + "bar", + "baz" + ] + }]; +} +message StringNotIn { + string val = 1 [(buf.validate.field).string = { + not_in: [ + "fizz", + "buzz" + ] + }]; +} +message StringLen { + string val = 1 [(buf.validate.field).string.len = 3]; +} +message StringMinLen { + string val = 1 [(buf.validate.field).string.min_len = 3]; +} +message StringMaxLen { + string val = 1 [(buf.validate.field).string.max_len = 5]; +} +message StringMinMaxLen { + string val = 1 [(buf.validate.field).string = { + min_len: 3 + max_len: 5 + }]; +} +message StringEqualMinMaxLen { + string val = 1 [(buf.validate.field).string = { + min_len: 5 + max_len: 5 + }]; +} +message StringLenBytes { + string val = 1 [(buf.validate.field).string.len_bytes = 4]; +} +message StringMinBytes { + string val = 1 [(buf.validate.field).string.min_bytes = 4]; +} +message StringMaxBytes { + string val = 1 [(buf.validate.field).string.max_bytes = 8]; +} +message StringMinMaxBytes { + string val = 1 [(buf.validate.field).string = { + min_bytes: 4 + max_bytes: 8 + }]; +} +message StringEqualMinMaxBytes { + string val = 1 [(buf.validate.field).string = { + min_bytes: 4 + max_bytes: 4 + }]; +} +message StringPattern { + string val = 1 [(buf.validate.field).string.pattern = "(?i)^[a-z0-9]+$"]; +} +message StringPatternEscapes { + string val = 1 [(buf.validate.field).string.pattern = "\\* \\\\ \\w"]; +} +message StringPrefix { + string val = 1 [(buf.validate.field).string.prefix = "foo"]; +} +message StringContains { + string val = 1 [(buf.validate.field).string.contains = "bar"]; +} +message StringNotContains { + string val = 1 [(buf.validate.field).string.not_contains = "bar"]; +} +message StringSuffix { + string val = 1 [(buf.validate.field).string.suffix = "baz"]; +} +message StringEmail { + string val = 1 [(buf.validate.field).string.email = true]; +} +message StringNotEmail { + string val = 1 [(buf.validate.field).string.email = false]; +} +message StringAddress { + string val = 1 [(buf.validate.field).string.address = true]; +} +message StringNotAddress { + string val = 1 [(buf.validate.field).string.address = false]; +} +message StringHostname { + string val = 1 [(buf.validate.field).string.hostname = true]; +} +message StringNotHostname { + string val = 1 [(buf.validate.field).string.hostname = false]; +} +message StringIP { + string val = 1 [(buf.validate.field).string.ip = true]; +} +message StringNotIP { + string val = 1 [(buf.validate.field).string.ip = false]; +} +message StringIPv4 { + string val = 1 [(buf.validate.field).string.ipv4 = true]; +} +message StringNotIPv4 { + string val = 1 [(buf.validate.field).string.ipv4 = false]; +} +message StringIPv6 { + string val = 1 [(buf.validate.field).string.ipv6 = true]; +} +message StringNotIPv6 { + string val = 1 [(buf.validate.field).string.ipv6 = false]; +} +message StringIPWithPrefixLen { + string val = 1 [(buf.validate.field).string.ip_with_prefixlen = true]; +} +message StringNotIPWithPrefixLen { + string val = 1 [(buf.validate.field).string.ip_with_prefixlen = false]; +} +message StringIPv4WithPrefixLen { + string val = 1 [(buf.validate.field).string.ipv4_with_prefixlen = true]; +} +message StringNotIPv4WithPrefixLen { + string val = 1 [(buf.validate.field).string.ipv4_with_prefixlen = false]; +} +message StringIPv6WithPrefixLen { + string val = 1 [(buf.validate.field).string.ipv6_with_prefixlen = true]; +} +message StringNotIPv6WithPrefixLen { + string val = 1 [(buf.validate.field).string.ipv6_with_prefixlen = false]; +} +message StringIPPrefix { + string val = 1 [(buf.validate.field).string.ip_prefix = true]; +} +message StringNotIPPrefix { + string val = 1 [(buf.validate.field).string.ip_prefix = false]; +} +message StringIPv4Prefix { + string val = 1 [(buf.validate.field).string.ipv4_prefix = true]; +} +message StringNotIPv4Prefix { + string val = 1 [(buf.validate.field).string.ipv4_prefix = false]; +} +message StringIPv6Prefix { + string val = 1 [(buf.validate.field).string.ipv6_prefix = true]; +} +message StringNotIPv6Prefix { + string val = 1 [(buf.validate.field).string.ipv6_prefix = false]; +} +message StringURI { + string val = 1 [(buf.validate.field).string.uri = true]; +} +message StringNotURI { + string val = 1 [(buf.validate.field).string.uri = false]; +} +message StringURIRef { + string val = 1 [(buf.validate.field).string.uri_ref = true]; +} +message StringNotURIRef { + string val = 1 [(buf.validate.field).string.uri_ref = false]; +} +message StringUUID { + string val = 1 [(buf.validate.field).string.uuid = true]; +} +message StringNotUUID { + string val = 1 [(buf.validate.field).string.uuid = false]; +} +message StringTUUID { + string val = 1 [(buf.validate.field).string.tuuid = true]; +} +message StringNotTUUID { + string val = 1 [(buf.validate.field).string.tuuid = false]; +} +message StringULID { + string val = 1 [(buf.validate.field).string.ulid = true]; +} +message StringNotULID { + string val = 1 [(buf.validate.field).string.ulid = false]; +} +message StringULIDIgnore { + string val = 1 [ + (buf.validate.field).string = {ulid: true}, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} +message StringHttpHeaderName { + string val = 1 [(buf.validate.field).string.well_known_regex = KNOWN_REGEX_HTTP_HEADER_NAME]; +} +message StringHttpHeaderValue { + string val = 1 [(buf.validate.field).string.well_known_regex = KNOWN_REGEX_HTTP_HEADER_VALUE]; +} + +message StringHttpHeaderNameLoose { + string val = 1 [(buf.validate.field).string = { + well_known_regex: KNOWN_REGEX_HTTP_HEADER_NAME + strict: false + }]; +} + +message StringHttpHeaderValueLoose { + string val = 1 [(buf.validate.field).string = { + well_known_regex: KNOWN_REGEX_HTTP_HEADER_VALUE + strict: false + }]; +} + +message StringUUIDIgnore { + string val = 1 [ + (buf.validate.field).string = {uuid: true}, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} +message StringInOneof { + oneof foo { + string bar = 1 [(buf.validate.field).string = { + in: "a" + in: "b" + }]; + } +} + +message StringHostAndPort { + string val = 1 [(buf.validate.field).string.host_and_port = true]; +} + +message StringHostAndOptionalPort { + string val = 1 [(field).cel = { + id: "string.host_and_port.optional_port" + message: "value must be a host and (optional) port pair" + expression: "this.isHostAndPort(false)" + }]; +} + +message StringExample { + string val = 1 [(buf.validate.field).string.example = "foo"]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/bea010505fbf083ab86ec3a6b6b5c94c7abaff58ca5460817e31a406831ad4ac4fab42f0de0ce2fa3f712fea72cb5d2510a2d225d2f6f2b8593ce3c2d4869e36 b/modules/sync/bufbuild/protovalidate-testing/cas/bea010505fbf083ab86ec3a6b6b5c94c7abaff58ca5460817e31a406831ad4ac4fab42f0de0ce2fa3f712fea72cb5d2510a2d225d2f6f2b8593ce3c2d4869e36 new file mode 100644 index 00000000..12a065dc --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/bea010505fbf083ab86ec3a6b6b5c94c7abaff58ca5460817e31a406831ad4ac4fab42f0de0ce2fa3f712fea72cb5d2510a2d225d2f6f2b8593ce3c2d4869e36 @@ -0,0 +1,224 @@ +// Copyright 2023-2026 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/conformance/cases/predefined_rules_proto2.proto"; +import "buf/validate/conformance/cases/predefined_rules_proto_editions.proto"; +import "buf/validate/validate.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +message PredefinedFloatRuleProto3 { + float val = 1 [(buf.validate.field).float.(float_abs_range_proto2) = 1.0]; +} + +message PredefinedDoubleRuleProto3 { + double val = 1 [(buf.validate.field).double.(double_abs_range_proto2) = 1.0]; +} + +message PredefinedInt32RuleProto3 { + int32 val = 1 [(buf.validate.field).int32.(int32_abs_in_proto2) = -2]; +} + +message PredefinedInt64RuleProto3 { + int64 val = 1 [(buf.validate.field).int64.(int64_abs_in_edition_2023) = {value: -2}]; +} + +message PredefinedUInt32RuleProto3 { + uint32 val = 1 [(buf.validate.field).uint32.(uint32_even_proto2) = true]; +} + +message PredefinedUInt64RuleProto3 { + uint64 val = 1 [(buf.validate.field).uint64.(uint64_even_proto2) = true]; +} + +message PredefinedSInt32RuleProto3 { + sint32 val = 1 [(buf.validate.field).sint32.(sint32_even_proto2) = true]; +} + +message PredefinedSInt64RuleProto3 { + sint64 val = 1 [(buf.validate.field).sint64.(sint64_even_proto2) = true]; +} + +message PredefinedFixed32RuleProto3 { + fixed32 val = 1 [(buf.validate.field).fixed32.(fixed32_even_proto2) = true]; +} + +message PredefinedFixed64RuleProto3 { + fixed64 val = 1 [(buf.validate.field).fixed64.(fixed64_even_proto2) = true]; +} + +message PredefinedSFixed32RuleProto3 { + sfixed32 val = 1 [(buf.validate.field).sfixed32.(sfixed32_even_proto2) = true]; +} + +message PredefinedSFixed64RuleProto3 { + sfixed64 val = 1 [(buf.validate.field).sfixed64.(sfixed64_even_proto2) = true]; +} + +message PredefinedBoolRuleProto3 { + bool val = 1 [(buf.validate.field).bool.(bool_false_proto2) = true]; +} + +message PredefinedStringRuleProto3 { + string val = 1 [(buf.validate.field).string.(string_valid_path_proto2) = true]; +} + +message PredefinedBytesRuleProto3 { + bytes val = 1 [(buf.validate.field).bytes.(bytes_valid_path_proto2) = true]; +} + +message PredefinedEnumRuleProto3 { + enum EnumProto3 { + ENUM_PROTO3_ZERO_UNSPECIFIED = 0; + ENUM_PROTO3_ONE = 1; + } + EnumProto3 val = 1 [(buf.validate.field).enum.(enum_non_zero_proto2) = true]; +} + +message PredefinedMapRuleProto3 { + map val = 1 [(buf.validate.field).map.(map_at_least_five_edition_2023) = true]; +} + +message PredefinedRepeatedRuleProto3 { + repeated uint64 val = 1 [(buf.validate.field).repeated.(repeated_at_least_five_proto2) = true]; +} + +message PredefinedDurationRuleProto3 { + google.protobuf.Duration val = 1 [(buf.validate.field).duration.(duration_too_long_proto2) = true]; +} + +message PredefinedTimestampRuleProto3 { + google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.(timestamp_in_range_proto2) = true]; +} + +message PredefinedWrappedFloatRuleProto3 { + google.protobuf.FloatValue val = 1 [(buf.validate.field).float.(float_abs_range_proto2) = 1.0]; +} + +message PredefinedWrappedDoubleRuleProto3 { + google.protobuf.DoubleValue val = 1 [(buf.validate.field).double.(double_abs_range_proto2) = 1.0]; +} + +message PredefinedWrappedInt32RuleProto3 { + google.protobuf.Int32Value val = 1 [(buf.validate.field).int32.(int32_abs_in_proto2) = -2]; +} + +message PredefinedWrappedInt64RuleProto3 { + google.protobuf.Int64Value val = 1 [(buf.validate.field).int64.(int64_abs_in_proto2) = {value: -2}]; +} + +message PredefinedWrappedUInt32RuleProto3 { + google.protobuf.UInt32Value val = 1 [(buf.validate.field).uint32.(uint32_even_proto2) = true]; +} + +message PredefinedWrappedUInt64RuleProto3 { + google.protobuf.UInt64Value val = 1 [(buf.validate.field).uint64.(uint64_even_proto2) = true]; +} + +message PredefinedWrappedBoolRuleProto3 { + google.protobuf.BoolValue val = 1 [(buf.validate.field).bool.(bool_false_proto2) = true]; +} + +message PredefinedWrappedStringRuleProto3 { + google.protobuf.StringValue val = 1 [(buf.validate.field).string.(string_valid_path_proto2) = true]; +} + +message PredefinedWrappedBytesRuleProto3 { + google.protobuf.BytesValue val = 1 [(buf.validate.field).bytes.(bytes_valid_path_proto2) = true]; +} + +message PredefinedRepeatedWrappedFloatRuleProto3 { + repeated google.protobuf.FloatValue val = 1 [(buf.validate.field).repeated.items.float.(float_abs_range_proto2) = 1.0]; +} + +message PredefinedRepeatedWrappedDoubleRuleProto3 { + repeated google.protobuf.DoubleValue val = 1 [(buf.validate.field).repeated.items.double.(double_abs_range_proto2) = 1.0]; +} + +message PredefinedRepeatedWrappedInt32RuleProto3 { + repeated google.protobuf.Int32Value val = 1 [(buf.validate.field).repeated.items.int32.(int32_abs_in_proto2) = -2]; +} + +message PredefinedRepeatedWrappedInt64RuleProto3 { + repeated google.protobuf.Int64Value val = 1 [(buf.validate.field).repeated.items.int64.(int64_abs_in_proto2) = {value: -2}]; +} + +message PredefinedRepeatedWrappedUInt32RuleProto3 { + repeated google.protobuf.UInt32Value val = 1 [(buf.validate.field).repeated.items.uint32.(uint32_even_proto2) = true]; +} + +message PredefinedRepeatedWrappedUInt64RuleProto3 { + repeated google.protobuf.UInt64Value val = 1 [(buf.validate.field).repeated.items.uint64.(uint64_even_proto2) = true]; +} + +message PredefinedRepeatedWrappedBoolRuleProto3 { + repeated google.protobuf.BoolValue val = 1 [(buf.validate.field).repeated.items.bool.(bool_false_proto2) = true]; +} + +message PredefinedRepeatedWrappedStringRuleProto3 { + repeated google.protobuf.StringValue val = 1 [(buf.validate.field).repeated.items.string.(string_valid_path_proto2) = true]; +} + +message PredefinedRepeatedWrappedBytesRuleProto3 { + repeated google.protobuf.BytesValue val = 1 [(buf.validate.field).repeated.items.bytes.(bytes_valid_path_proto2) = true]; +} + +message PredefinedAndCustomRuleProto3 { + sint32 a = 1 [ + (field).cel = { + id: "predefined_and_custom_rule_scalar_proto3" + expression: "this > 24 ? '' : 'a must be greater than 24'" + }, + (field).sint32.(sint32_even_edition_2023) = true + ]; + + optional Nested b = 2 [(field).cel = { + id: "predefined_and_custom_rule_embedded_proto3" + message: "b.c must be a multiple of 3" + expression: "this.c % 3 == 0" + }]; + + message Nested { + sint32 c = 1 [ + (field).cel = { + id: "predefined_and_custom_rule_nested_proto3" + expression: "this > 0 ? '' : 'c must be positive'" + }, + (field).sint32.(sint32_even_edition_2023) = true + ]; + } +} + +message StandardPredefinedAndCustomRuleProto3 { + sint32 a = 1 [ + (field).sint32.lt = 28, + (field).sint32.(sint32_even_proto2) = true, + (field).cel = { + id: "standard_predefined_and_custom_rule_scalar_proto3" + expression: "this > 24 ? '' : 'a must be greater than 24'" + } + ]; +} + +// This is a workaround for https://github.com/bufbuild/buf/issues/3306. +// TODO(jchadwick-buf): Remove this when bufbuild/buf#3306 is fixed. +message PredefinedRulesProto3UnusedImportBugWorkaround { + StandardPredefinedAndCustomRuleProto2 dummy_1 = 1; + StandardPredefinedAndCustomRuleEdition2023 dummy_2 = 2; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/ca0148e4a87f4b3e50df8a2786c81af6cfd50b3634aeb5e09dadeca86e30604ff851e392476d65f8fbaff0c6ccdddf4e25c7d5b5cf3bb9987912feb051ac9c5b b/modules/sync/bufbuild/protovalidate-testing/cas/ca0148e4a87f4b3e50df8a2786c81af6cfd50b3634aeb5e09dadeca86e30604ff851e392476d65f8fbaff0c6ccdddf4e25c7d5b5cf3bb9987912feb051ac9c5b new file mode 100644 index 00000000..77876a26 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/ca0148e4a87f4b3e50df8a2786c81af6cfd50b3634aeb5e09dadeca86e30604ff851e392476d65f8fbaff0c6ccdddf4e25c7d5b5cf3bb9987912feb051ac9c5b @@ -0,0 +1,166 @@ +// Copyright 2023-2026 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/conformance/cases/other_package/embed.proto"; +import "buf/validate/validate.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; + +message Embed { + int64 val = 1 [(buf.validate.field).int64.gt = 0]; +} +enum AnEnum { + AN_ENUM_UNSPECIFIED = 0; + AN_ENUM_X = 1; + AN_ENUM_Y = 2; +} + +message RepeatedNone { + repeated int64 val = 1; +} +message RepeatedEmbedNone { + repeated Embed val = 1; +} +message RepeatedEmbedCrossPackageNone { + repeated other_package.Embed val = 1; +} +message RepeatedMin { + repeated Embed val = 1 [(buf.validate.field).repeated.min_items = 2]; +} +message RepeatedMax { + repeated double val = 1 [(buf.validate.field).repeated.max_items = 3]; +} +message RepeatedMinMax { + repeated sfixed32 val = 1 [(buf.validate.field).repeated = { + min_items: 2 + max_items: 4 + }]; +} +message RepeatedExact { + repeated uint32 val = 1 [(buf.validate.field).repeated = { + min_items: 3 + max_items: 3 + }]; +} +message RepeatedUnique { + repeated string val = 1 [(buf.validate.field).repeated.unique = true]; +} +message RepeatedNotUnique { + repeated string val = 1 [(buf.validate.field).repeated.unique = false]; +} +message RepeatedMultipleUnique { + repeated string a = 1 [(buf.validate.field).repeated.unique = true]; + repeated int32 b = 2 [(buf.validate.field).repeated.unique = true]; +} +message RepeatedItemRule { + repeated float val = 1 [(buf.validate.field).repeated.items.float.gt = 0]; +} +message RepeatedItemPattern { + repeated string val = 1 [(buf.validate.field).repeated.items.string.pattern = "(?i)^[a-z0-9]+$"]; +} +message RepeatedEmbedSkip { + repeated Embed val = 1 [(buf.validate.field).repeated.items.ignore = IGNORE_ALWAYS]; +} +message RepeatedItemIn { + repeated string val = 1 [(buf.validate.field).repeated.items.string = { + in: [ + "foo", + "bar" + ] + }]; +} +message RepeatedItemNotIn { + repeated string val = 1 [(buf.validate.field).repeated.items.string = { + not_in: [ + "foo", + "bar" + ] + }]; +} +message RepeatedEnumIn { + repeated AnEnum val = 1 [(buf.validate.field).repeated.items.enum = { + in: [0] + }]; +} +message RepeatedEnumNotIn { + repeated AnEnum val = 1 [(buf.validate.field).repeated.items.enum = { + not_in: [0] + }]; +} +message RepeatedEmbeddedEnumIn { + repeated AnotherInEnum val = 1 [(buf.validate.field).repeated.items.enum = { + in: [0] + }]; + enum AnotherInEnum { + ANOTHER_IN_ENUM_UNSPECIFIED = 0; + ANOTHER_IN_ENUM_A = 1; + ANOTHER_IN_ENUM_B = 2; + } +} +message RepeatedEmbeddedEnumNotIn { + repeated AnotherNotInEnum val = 1 [(buf.validate.field).repeated.items.enum = { + not_in: [0] + }]; + enum AnotherNotInEnum { + ANOTHER_NOT_IN_ENUM_UNSPECIFIED = 0; + ANOTHER_NOT_IN_ENUM_A = 1; + ANOTHER_NOT_IN_ENUM_B = 2; + } +} +message RepeatedAnyIn { + repeated google.protobuf.Any val = 1 [(buf.validate.field).repeated.items.any = { + in: ["type.googleapis.com/google.protobuf.Duration"] + }]; +} +message RepeatedAnyNotIn { + repeated google.protobuf.Any val = 1 [(buf.validate.field).repeated.items.any = { + not_in: ["type.googleapis.com/google.protobuf.Timestamp"] + }]; +} +message RepeatedMinAndItemLen { + repeated string val = 1 [(buf.validate.field).repeated = { + items: { + string: {len: 3} + } + min_items: 1 + }]; +} +message RepeatedMinAndMaxItemLen { + repeated string val = 1 [ + (buf.validate.field).repeated.min_items = 1, + (buf.validate.field).repeated.max_items = 3 + ]; +} +message RepeatedDuration { + repeated google.protobuf.Duration val = 1 [(buf.validate.field).repeated = { + items: { + duration: { + gte: {nanos: 1000000} + } + } + }]; +} +message RepeatedExactIgnore { + repeated uint32 val = 1 [ + (buf.validate.field).repeated = { + min_items: 3 + max_items: 3 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/cc2374179d58436e4ad321d075df99b2ba42fce4334c8a06e3fd6ccfe476d14e7aea4263bd9755db061ba7c826ba44497d614ebc480aa750799192b0172655bb b/modules/sync/bufbuild/protovalidate-testing/cas/cc2374179d58436e4ad321d075df99b2ba42fce4334c8a06e3fd6ccfe476d14e7aea4263bd9755db061ba7c826ba44497d614ebc480aa750799192b0172655bb new file mode 100644 index 00000000..de2fd2a0 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/cc2374179d58436e4ad321d075df99b2ba42fce4334c8a06e3fd6ccfe476d14e7aea4263bd9755db061ba7c826ba44497d614ebc480aa750799192b0172655bb @@ -0,0 +1,19 @@ +// Copyright 2023-2026 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.subdirectory; + +import "buf/validate/validate.proto"; diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/d194a33bd8dc13bd7b56db8c4793c548cc2d3deebf1a49c98213b9f424e4454c1df5d8d6301a3a3884dad881a642eafb739e16b499fec99649ca0dc46e9c5408 b/modules/sync/bufbuild/protovalidate-testing/cas/d194a33bd8dc13bd7b56db8c4793c548cc2d3deebf1a49c98213b9f424e4454c1df5d8d6301a3a3884dad881a642eafb739e16b499fec99649ca0dc46e9c5408 new file mode 100644 index 00000000..5fa6c65b --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/d194a33bd8dc13bd7b56db8c4793c548cc2d3deebf1a49c98213b9f424e4454c1df5d8d6301a3a3884dad881a642eafb739e16b499fec99649ca0dc46e9c5408 @@ -0,0 +1,65 @@ +// Copyright 2023-2026 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"; +import "google/protobuf/any.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +message AnyNone { + google.protobuf.Any val = 1; +} +message AnyRequired { + google.protobuf.Any val = 1 [(buf.validate.field).required = true]; +} +message AnyIn { + google.protobuf.Any val = 1 [(buf.validate.field).any = { + in: ["type.googleapis.com/google.protobuf.Duration"] + }]; +} +message AnyNotIn { + google.protobuf.Any val = 1 [(buf.validate.field).any = { + not_in: ["type.googleapis.com/google.protobuf.Timestamp"] + }]; +} + +// The below messages should throw compilation errors due to incorrect types. +message AnyWrongTypeScalar { + string val = 1 [(buf.validate.field).any = { + not_in: ["type.googleapis.com/google.protobuf.Timestamp"] + }]; +} +message AnyWrongTypeMessage { + message WrongType { + int32 val = 1; + } + WrongType val = 1 [(buf.validate.field).any = { + not_in: ["type.googleapis.com/google.protobuf.Timestamp"] + }]; +} +message AnyWrongTypeWrapper { + google.protobuf.Int32Value val = 1 [(buf.validate.field).any = { + not_in: ["type.googleapis.com/google.protobuf.Timestamp"] + }]; +} + +message AnyWrongTypeWKT { + google.protobuf.Timestamp val = 1 [(buf.validate.field).any = { + not_in: ["type.googleapis.com/google.protobuf.Timestamp"] + }]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/d95e4d1e9ab99dd39fa6fcea8b206a9fea5ad3891741139dab1bc13010bacae2e6e7e35b96d4a0104ef958cc2622bc0a59d3ef66517d7d22672b28b11ec22943 b/modules/sync/bufbuild/protovalidate-testing/cas/d95e4d1e9ab99dd39fa6fcea8b206a9fea5ad3891741139dab1bc13010bacae2e6e7e35b96d4a0104ef958cc2622bc0a59d3ef66517d7d22672b28b11ec22943 new file mode 100644 index 00000000..4a14705b --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/d95e4d1e9ab99dd39fa6fcea8b206a9fea5ad3891741139dab1bc13010bacae2e6e7e35b96d4a0104ef958cc2622bc0a59d3ef66517d7d22672b28b11ec22943 @@ -0,0 +1,79 @@ +// Copyright 2023-2026 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 MapNone { + map val = 1; +} + +message MapMin { + map val = 1 [(buf.validate.field).map.min_pairs = 2]; +} +message MapMax { + map val = 1 [(buf.validate.field).map.max_pairs = 3]; +} +message MapMinMax { + map val = 1 [(buf.validate.field).map = { + min_pairs: 2 + max_pairs: 4 + }]; +} +message MapExact { + map val = 1 [(buf.validate.field).map = { + min_pairs: 3 + max_pairs: 3 + }]; +} + +message MapKeys { + map val = 1 [(buf.validate.field).map.keys.sint64.lt = 0]; +} +message MapValues { + map val = 1 [(buf.validate.field).map.values.string.min_len = 3]; +} + +message MapKeysPattern { + map val = 1 [(buf.validate.field).map.keys.string.pattern = "(?i)^[a-z0-9]+$"]; +} +message MapValuesPattern { + map val = 1 [(buf.validate.field).map.values.string.pattern = "(?i)^[a-z0-9]+$"]; +} + +message MapRecursive { + map val = 1; + message Msg { + string val = 1 [(buf.validate.field).string.min_len = 3]; + } +} + +message MapExactIgnore { + map val = 1 [ + (buf.validate.field).map = { + min_pairs: 3 + max_pairs: 3 + }, + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE + ]; +} + +message MultipleMaps { + map first = 1 [(buf.validate.field).map.keys.uint32.gt = 0]; + map second = 2 [(buf.validate.field).map.keys.int32.lt = 0]; + map third = 3 [(buf.validate.field).map.keys.int32.gt = 0]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/de0ade06ce5a50c5a971fb235ff8536244d1783e80309c686102e49fd0363956cfa8dec44975c25794224df5c65220f71d42bdd787aae42a4d0843c3d9c2711f b/modules/sync/bufbuild/protovalidate-testing/cas/de0ade06ce5a50c5a971fb235ff8536244d1783e80309c686102e49fd0363956cfa8dec44975c25794224df5c65220f71d42bdd787aae42a4d0843c3d9c2711f new file mode 100644 index 00000000..8da2703a --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/de0ade06ce5a50c5a971fb235ff8536244d1783e80309c686102e49fd0363956cfa8dec44975c25794224df5c65220f71d42bdd787aae42a4d0843c3d9c2711f @@ -0,0 +1,31 @@ +// Copyright 2023-2026 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 WktLevelOne { + message WktLevelTwo { + message WktLevelThree { + string uuid = 1 [(buf.validate.field).string.uuid = true]; + } + + WktLevelThree three = 1 [(buf.validate.field).required = true]; + } + + WktLevelTwo two = 1 [(buf.validate.field).required = true]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/e5726d498e20865b97300411c0ce44a02fca0f6879ed59606e0e83aed0679e23ddf6e1da724fdb9e613b5c9782b7a3791ed127eddbdf60b1268b48cb56b33385 b/modules/sync/bufbuild/protovalidate-testing/cas/e5726d498e20865b97300411c0ce44a02fca0f6879ed59606e0e83aed0679e23ddf6e1da724fdb9e613b5c9782b7a3791ed127eddbdf60b1268b48cb56b33385 new file mode 100644 index 00000000..e6f6571d --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/e5726d498e20865b97300411c0ce44a02fca0f6879ed59606e0e83aed0679e23ddf6e1da724fdb9e613b5c9782b7a3791ed127eddbdf60b1268b48cb56b33385 @@ -0,0 +1,56 @@ +// Copyright 2023-2026 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"; +import "google/protobuf/field_mask.proto"; + +message FieldMaskNone { + google.protobuf.FieldMask val = 1; +} +message FieldMaskRequired { + google.protobuf.FieldMask val = 1 [(buf.validate.field).required = true]; +} + +message FieldMaskConst { + google.protobuf.FieldMask val = 1 [(buf.validate.field).field_mask.const = { + paths: ["a"] + }]; +} + +message FieldMaskIn { + google.protobuf.FieldMask val = 1 [(buf.validate.field).field_mask = { + in: [ + "a", + "b" + ] + }]; +} +message FieldMaskNotIn { + google.protobuf.FieldMask val = 1 [(buf.validate.field).field_mask = { + not_in: [ + "c", + "d" + ] + }]; +} + +message FieldMaskExample { + google.protobuf.FieldMask val = 1 [(buf.validate.field).field_mask.example = { + paths: ["a"] + }]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/e702a95ca4516da9365b47a96282a3997660ecff5f614135d19a480ae7e9fb7fc0780efa034d133b95f5fe214a9fe4dd1cd65a9a9b6362db5f07792c0b699f38 b/modules/sync/bufbuild/protovalidate-testing/cas/e702a95ca4516da9365b47a96282a3997660ecff5f614135d19a480ae7e9fb7fc0780efa034d133b95f5fe214a9fe4dd1cd65a9a9b6362db5f07792c0b699f38 new file mode 100644 index 00000000..347d9fc9 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/e702a95ca4516da9365b47a96282a3997660ecff5f614135d19a480ae7e9fb7fc0780efa034d133b95f5fe214a9fe4dd1cd65a9a9b6362db5f07792c0b699f38 @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2023-2026 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. diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/e790f9ea5503a6955f45c45dcb8a5700d35846e36600b08c0471d66f6062b4f2c3479220c0b7be814c6888bfff0f3dcc051c09a84545aa39ca566d79f7e8de40 b/modules/sync/bufbuild/protovalidate-testing/cas/e790f9ea5503a6955f45c45dcb8a5700d35846e36600b08c0471d66f6062b4f2c3479220c0b7be814c6888bfff0f3dcc051c09a84545aa39ca566d79f7e8de40 new file mode 100644 index 00000000..00ba7845 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/e790f9ea5503a6955f45c45dcb8a5700d35846e36600b08c0471d66f6062b4f2c3479220c0b7be814c6888bfff0f3dcc051c09a84545aa39ca566d79f7e8de40 @@ -0,0 +1,73 @@ +// Copyright 2023-2026 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"; +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +enum ComplexTestEnum { + COMPLEX_TEST_ENUM_UNSPECIFIED = 0; + COMPLEX_TEST_ENUM_ONE = 1; + COMPLEX_TEST_ENUM_TWO = 2; +} + +message ComplexTestMsg { + string const = 1 [(buf.validate.field).string.const = "abcd"]; + ComplexTestMsg nested = 2; + int32 int_const = 3 [(buf.validate.field).int32.const = 5]; + bool bool_const = 4 [(buf.validate.field).bool.const = false]; + google.protobuf.FloatValue float_val = 5 [(buf.validate.field).float.gt = 0]; + google.protobuf.Duration dur_val = 6 [ + (buf.validate.field).duration.lt = {seconds: 17}, + (buf.validate.field).required = true + ]; + google.protobuf.Timestamp ts_val = 7 [(buf.validate.field).timestamp.gt = {seconds: 7}]; + ComplexTestMsg another = 8; + float float_const = 9 [(buf.validate.field).float.lt = 8]; + double double_in = 10 [(buf.validate.field).double = { + in: [ + 456.789, + 123 + ] + }]; + ComplexTestEnum enum_const = 11 [(buf.validate.field).enum.const = 2]; + google.protobuf.Any any_val = 12 [(buf.validate.field).any = { + in: ["type.googleapis.com/google.protobuf.Duration"] + }]; + repeated google.protobuf.Timestamp rep_ts_val = 13 [(buf.validate.field).repeated = { + items: { + timestamp: { + gte: {nanos: 1000000} + } + } + }]; + map map_val = 14 [(buf.validate.field).map.keys.sint32.lt = 0]; + bytes bytes_val = 15 [(buf.validate.field).bytes.const = "\x00\x99"]; + oneof o { + option (buf.validate.oneof).required = true; + + string x = 16; + int32 y = 17; + } +} + +message KitchenSinkMessage { + ComplexTestMsg val = 1; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/e8db08f636106e6716c3a89bfa18a47dec10b47bd93801105861aec280e8deb21205a1f0bb28d9f58c76fbd9517ec9a9f206b0e6216eb019938d23432bfcbdba b/modules/sync/bufbuild/protovalidate-testing/cas/e8db08f636106e6716c3a89bfa18a47dec10b47bd93801105861aec280e8deb21205a1f0bb28d9f58c76fbd9517ec9a9f206b0e6216eb019938d23432bfcbdba new file mode 100644 index 00000000..09d98da1 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/e8db08f636106e6716c3a89bfa18a47dec10b47bd93801105861aec280e8deb21205a1f0bb28d9f58c76fbd9517ec9a9f206b0e6216eb019938d23432bfcbdba @@ -0,0 +1,127 @@ +// Copyright 2023-2026 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/conformance/cases/other_package/embed.proto"; +import "buf/validate/conformance/cases/yet_another_package/embed2.proto"; +import "buf/validate/validate.proto"; + +enum TestEnum { + TEST_ENUM_UNSPECIFIED = 0; + TEST_ENUM_ONE = 1; + TEST_ENUM_TWO = 2; +} + +enum TestEnumAlias { + option allow_alias = true; + + TEST_ENUM_ALIAS_UNSPECIFIED = 0; + TEST_ENUM_ALIAS_A = 1; + TEST_ENUM_ALIAS_B = 2; + TEST_ENUM_ALIAS_C = 3; + + TEST_ENUM_ALIAS_ALPHA = 1; + TEST_ENUM_ALIAS_BETA = 2; + TEST_ENUM_ALIAS_GAMMA = 3; +} + +message EnumNone { + TestEnum val = 1; +} + +message EnumConst { + TestEnum val = 1 [(buf.validate.field).enum.const = 2]; +} +message EnumAliasConst { + TestEnumAlias val = 1 [(buf.validate.field).enum.const = 2]; +} + +message EnumDefined { + TestEnum val = 1 [(buf.validate.field).enum.defined_only = true]; +} +message EnumAliasDefined { + TestEnumAlias val = 1 [(buf.validate.field).enum.defined_only = true]; +} + +message EnumIn { + TestEnum val = 1 [(buf.validate.field).enum = { + in: [ + 0, + 2 + ] + }]; +} +message EnumAliasIn { + TestEnumAlias val = 1 [(buf.validate.field).enum = { + in: [ + 0, + 2 + ] + }]; +} + +message EnumNotIn { + TestEnum val = 1 [(buf.validate.field).enum = { + not_in: [1] + }]; +} +message EnumAliasNotIn { + TestEnumAlias val = 1 [(buf.validate.field).enum = { + not_in: [1] + }]; +} + +message EnumExternal { + other_package.Embed.Enumerated val = 1 [(buf.validate.field).enum.defined_only = true]; +} +message EnumExternal2 { + other_package.Embed.DoubleEmbed.DoubleEnumerated val = 1 [(buf.validate.field).enum.defined_only = true]; +} + +message RepeatedEnumDefined { + repeated TestEnum val = 1 [(buf.validate.field).repeated.items.enum.defined_only = true]; +} +message RepeatedExternalEnumDefined { + repeated other_package.Embed.Enumerated val = 1 [(buf.validate.field).repeated.items.enum.defined_only = true]; +} +message RepeatedYetAnotherExternalEnumDefined { + repeated yet_another_package.Embed.Enumerated val = 1 [(buf.validate.field).repeated.items.enum.defined_only = true]; +} + +message MapEnumDefined { + map val = 1 [(buf.validate.field).map.values.enum.defined_only = true]; +} +message MapExternalEnumDefined { + map val = 1 [(buf.validate.field).map.values.enum.defined_only = true]; +} + +message EnumInsideOneof { + oneof foo { + TestEnum val = 1 [(buf.validate.field).enum.defined_only = true]; + } + + oneof bar { + TestEnum val2 = 2 [(buf.validate.field).enum = { + defined_only: true + not_in: 0 + }]; + } +} + +message EnumExample { + TestEnum val = 1 [(buf.validate.field).enum.example = 2]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/f3acd2b171af96911432ac42c55a9fec37eaf1429e5fe72b5430c00ab36716b19443aaf78cd7cdb5b0a54b546a5f6cdd32b8f94ae1150fd9c291165adb6778c0 b/modules/sync/bufbuild/protovalidate-testing/cas/f3acd2b171af96911432ac42c55a9fec37eaf1429e5fe72b5430c00ab36716b19443aaf78cd7cdb5b0a54b546a5f6cdd32b8f94ae1150fd9c291165adb6778c0 new file mode 100644 index 00000000..d7dc9889 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/f3acd2b171af96911432ac42c55a9fec37eaf1429e5fe72b5430c00ab36716b19443aaf78cd7cdb5b0a54b546a5f6cdd32b8f94ae1150fd9c291165adb6778c0 @@ -0,0 +1,312 @@ +// Copyright 2023-2026 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.custom_rules; + +import "buf/validate/validate.proto"; + +enum Enum { + ENUM_UNSPECIFIED = 0; + ENUM_ONE = 1; +} + +// A message that does not contain any expressions +message NoExpressions { + int32 a = 1; + Enum b = 2; + Nested c = 3; + + message Nested {} +} + +// A message with message-level custom expressions +message MessageExpressions { + option (message).cel = { + id: "message_expression_scalar" + message: "a must be less than b" + expression: "this.a < this.b" + }; + option (message).cel = { + id: "message_expression_enum" + message: "c must not equal d" + expression: "this.c != this.d" + }; + option (message).cel = { + id: "message_expression_embed" + message: "e.a must equal f.a" + expression: "this.e.a == this.f.a" + }; + + int32 a = 1; + int32 b = 2; + Enum c = 3; + Enum d = 4; + Nested e = 5; + Nested f = 6; + + message Nested { + option (message).cel = { + id: "message_expression_nested" + expression: + "this.a > this.b ? ''" + ": 'a must be greater than b'" + }; + + int32 a = 1; + int32 b = 2; + } +} + +message MessageExpressionOnly { + option (message).cel_expression = "this.a > 0"; + + int32 a = 1; +} + +message MissingField { + option (message).cel = { + id: "missing_field" + message: "b must be positive" + expression: "this.b > 0" + }; + + int32 a = 1; +} + +message IncorrectType { + option (message).cel = { + id: "incorrect_type" + message: "a must start with 'foo'" + expression: "this.a.startsWith('foo')" + }; + + int32 a = 1; +} + +message DynRuntimeError { + option (message).cel = { + id: "dyn_runtime_err" + message: "dynamic type tries to use a non-existent field" + expression: "dyn(this).b == 'foo'" + }; + + int32 a = 1; +} + +message NowEqualsNow { + option (message).cel = { + id: "now_equals_now" + message: "now should equal now within an expression" + expression: "now == now" + }; +} + +message FieldExpressionOnly { + int32 val = 1 [(field).cel_expression = "this > 42"]; +} + +message FieldExpressionMultipleScalar { + int32 val = 1 [ + (field).cel = { + id: "field_expression.multiple.scalar.1" + message: "test message field_expression.multiple.scalar.1" + expression: "this > 0" + }, + (field).cel = { + id: "field_expression.multiple.scalar.2" + message: "test message field_expression.multiple.scalar.2" + expression: "this > 1" + }, + (field).cel = { + id: "field_expression.multiple.scalar.3" + message: "test message field_expression.multiple.scalar.3" + expression: "this > 2" + } + ]; +} +message FieldExpressionNestedScalar { + FieldExpressionScalar nested = 1; +} +message FieldExpressionOptionalScalar { + optional int32 val = 1 [(field).cel = { + id: "field_expression.optional.scalar" + message: "test message field_expression.optional.scalar" + expression: "this == 1" + }]; +} + +message FieldExpressionScalar { + int32 val = 1 [(field).cel = { + id: "field_expression.scalar" + message: "test message field_expression.scalar" + expression: "this == 1" + }]; +} +message FieldExpressionEnum { + Enum val = 1 [(field).cel = { + id: "field_expression.enum" + message: "test message field_expression.enum" + expression: "this == 1" + }]; +} +message FieldExpressionMessage { + Msg val = 1 [(field).cel = { + id: "field_expression.message" + message: "test message field_expression.message" + expression: "this.a == 1" + }]; + message Msg { + int32 a = 1; + } +} +message FieldExpressionMapInt32 { + map val = 1 [(buf.validate.field).cel = { + id: "field_expression.map.int32" + message: "all map values must equal 1" + expression: "this.all(k, this[k] == 1)" + }]; +} +message FieldExpressionMapInt64 { + map val = 1 [(buf.validate.field).cel = { + id: "field_expression.map.int64" + message: "all map values must equal 1" + expression: "this.all(k, this[k] == 1)" + }]; +} +message FieldExpressionMapUint32 { + map val = 1 [(buf.validate.field).cel = { + id: "field_expression.map.uint32" + message: "all map values must equal 1" + expression: "this.all(k, this[k] == uint(1))" + }]; +} +message FieldExpressionMapUint64 { + map val = 1 [(buf.validate.field).cel = { + id: "field_expression.map.uint64" + message: "all map values must equal 1" + expression: "this.all(k, this[k] == uint(1))" + }]; +} +message FieldExpressionMapBool { + map val = 1 [(buf.validate.field).cel = { + id: "field_expression.map.bool" + message: "all map values must equal false" + expression: "this.all(k, this[k] == false)" + }]; +} +message FieldExpressionMapString { + map val = 1 [(buf.validate.field).cel = { + id: "field_expression.map.string" + message: "all map values must equal 'foo'" + expression: "this.all(k, this[k] == 'foo')" + }]; +} +message FieldExpressionMapEnum { + map val = 1 [(buf.validate.field).cel = { + id: "field_expression.map.enum" + message: "test message field_expression.map.enum" + expression: "this.all(k, this[k] == 1)" + }]; +} +message FieldExpressionMapMessage { + map val = 1 [(buf.validate.field).cel = { + id: "field_expression.map.message" + message: "test message field_expression.map.message" + expression: "this.all(k, this[k].a == 1)" + }]; + message Msg { + int32 a = 1; + } +} +message FieldExpressionMapKeys { + map val = 1 [(buf.validate.field).map.keys.cel = { + id: "field_expression.map.keys" + message: "test message field_expression.map.keys" + expression: "this == 4 || this == 8" + }]; +} +message FieldExpressionMapScalarValues { + map val = 1 [(buf.validate.field).map.values.cel = { + id: "field_expression.map.scalar.values" + message: "test message field_expression.map.scalar.values" + expression: "this == 1" + }]; +} +message FieldExpressionMapEnumValues { + map val = 1 [(buf.validate.field).map.values.cel = { + id: "field_expression.map.enum.values" + message: "test message field_expression.map.enum.values" + expression: "this == 1" + }]; +} +message FieldExpressionMapMessageValues { + map val = 1 [(buf.validate.field).map.values.cel = { + id: "field_expression.map.message.values" + message: "test message field_expression.map.message.values" + expression: "this.a == 1" + }]; + message Msg { + int32 a = 1; + } +} +message FieldExpressionRepeatedScalar { + repeated int32 val = 1 [(buf.validate.field).cel = { + id: "field_expression.repeated.scalar" + message: "test message field_expression.repeated.scalar" + expression: "this.all(e, e == 1)" + }]; +} +message FieldExpressionRepeatedEnum { + repeated Enum val = 1 [(buf.validate.field).cel = { + id: "field_expression.repeated.enum" + message: "test message field_expression.repeated.enum" + expression: "this.all(e, e == 1)" + }]; +} +message FieldExpressionRepeatedMessage { + repeated Msg val = 1 [(buf.validate.field).cel = { + id: "field_expression.repeated.message" + message: "test message field_expression.repeated.message" + expression: "this.all(e, e.a == 1)" + }]; + message Msg { + int32 a = 1; + } +} +message FieldExpressionRepeatedScalarItems { + repeated int32 val = 1 [(buf.validate.field).repeated.items.cel = { + id: "field_expression.repeated.scalar.items" + message: "test message field_expression.repeated.scalar.items" + expression: "this == 1" + }]; +} +message FieldExpressionRepeatedEnumItems { + repeated Enum val = 1 [(buf.validate.field).repeated.items.cel = { + id: "field_expression.repeated.enum.items" + message: "test message field_expression.repeated.enum.items" + expression: "this == 1" + }]; +} +message FieldExpressionRepeatedMessageItems { + repeated Msg val = 1 [(buf.validate.field).repeated.items.cel = { + id: "field_expression.repeated.message.items" + message: "test message field_expression.repeated.message.items" + expression: "this.a == 1" + }]; + message Msg { + int32 a = 1; + } +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/f93514ac3a94aba4b51099c349a8ff1ff7016cc04162573177d7aba8eebd4c1984819fd429f3e3cd3db5e5efd1d828d304dd05e24e28e05fa508362a6b513aeb b/modules/sync/bufbuild/protovalidate-testing/cas/f93514ac3a94aba4b51099c349a8ff1ff7016cc04162573177d7aba8eebd4c1984819fd429f3e3cd3db5e5efd1d828d304dd05e24e28e05fa508362a6b513aeb new file mode 100644 index 00000000..a7e03422 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/f93514ac3a94aba4b51099c349a8ff1ff7016cc04162573177d7aba8eebd4c1984819fd429f3e3cd3db5e5efd1d828d304dd05e24e28e05fa508362a6b513aeb @@ -0,0 +1,361 @@ +// Copyright 2023-2026 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"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +extend buf.validate.FloatRules { + optional float float_abs_range_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "float.abs_range.proto2" + expression: "this >= -rule && this <= rule" + message: "float value is out of range" + }]; +} + +extend buf.validate.DoubleRules { + optional double double_abs_range_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "double.abs_range.proto2" + expression: "this >= -rule && this <= rule" + message: "double value is out of range" + }]; +} + +extend buf.validate.Int32Rules { + repeated int32 int32_abs_in_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "int32.abs_in.proto2" + expression: "this in rule || this in rule.map(n, -n)" + message: "value must be in absolute value of list" + }]; +} + +extend buf.validate.Int64Rules { + repeated google.protobuf.Int64Value int64_abs_in_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "int64.abs_in.proto2" + expression: "this in rule || this in rule.map(n, -n)" + message: "value must be in absolute value of list" + }]; +} + +extend buf.validate.UInt32Rules { + optional bool uint32_even_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "uint32.even.proto2" + expression: "this % 2u == 0u" + message: "uint32 value is not even" + }]; +} + +extend buf.validate.UInt64Rules { + optional bool uint64_even_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "uint64.even.proto2" + expression: "this % 2u == 0u" + message: "uint64 value is not even" + }]; +} + +extend buf.validate.SInt32Rules { + optional bool sint32_even_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "sint32.even.proto2" + expression: "this % 2 == 0" + message: "sint32 value is not even" + }]; +} + +extend buf.validate.SInt64Rules { + optional bool sint64_even_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "sint64.even.proto2" + expression: "this % 2 == 0" + message: "sint64 value is not even" + }]; +} + +extend buf.validate.Fixed32Rules { + optional bool fixed32_even_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "fixed32.even.proto2" + expression: "this % 2u == 0u" + message: "fixed32 value is not even" + }]; +} + +extend buf.validate.Fixed64Rules { + optional bool fixed64_even_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "fixed64.even.proto2" + expression: "this % 2u == 0u" + message: "fixed64 value is not even" + }]; +} + +extend buf.validate.SFixed32Rules { + optional bool sfixed32_even_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "sfixed32.even.proto2" + expression: "this % 2 == 0" + message: "sfixed32 value is not even" + }]; +} + +extend buf.validate.SFixed64Rules { + optional bool sfixed64_even_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "sfixed64.even.proto2" + expression: "this % 2 == 0" + message: "sfixed64 value is not even" + }]; +} + +extend buf.validate.BoolRules { + optional bool bool_false_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "bool.false.proto2" + expression: "this == false" + message: "bool value is not false" + }]; +} + +extend buf.validate.StringRules { + optional bool string_valid_path_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "string.valid_path.proto2" + expression: "!this.matches('^([^/.][^/]?|[^/][^/.]|[^/]{3,})(/([^/.][^/]?|[^/][^/.]|[^/]{3,}))*$') ? 'not a valid path: `%s`'.format([this]) : ''" + }]; +} + +extend buf.validate.BytesRules { + optional bool bytes_valid_path_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "bytes.valid_path.proto2" + expression: "!string(this).matches('^([^/.][^/]?|[^/][^/.]|[^/]{3,})(/([^/.][^/]?|[^/][^/.]|[^/]{3,}))*$') ? 'not a valid path: `%s`'.format([this]) : ''" + }]; +} + +extend buf.validate.EnumRules { + optional bool enum_non_zero_proto2 = 1161 [(buf.validate.predefined).cel = { + id: "enum.non_zero.proto2" + expression: "int(this) != 0" + message: "enum value is not non-zero" + }]; +} + +extend buf.validate.RepeatedRules { + optional bool repeated_at_least_five_proto2 = 1161 [(predefined).cel = { + id: "repeated.at_least_five.proto2" + expression: "uint(this.size()) >= 5u" + message: "repeated field must have at least five values" + }]; +} + +extend buf.validate.DurationRules { + optional bool duration_too_long_proto2 = 1161 [(predefined).cel = { + id: "duration.too_long.proto2" + expression: "this <= duration('10s')" + message: "duration can't be longer than 10 seconds" + }]; +} + +extend buf.validate.TimestampRules { + optional bool timestamp_in_range_proto2 = 1161 [(predefined).cel = { + id: "timestamp.time_range.proto2" + expression: "int(this) >= 1049587200 && int(this) <= 1080432000" + message: "timestamp out of range" + }]; +} + +message PredefinedFloatRuleProto2 { + optional float val = 1 [(buf.validate.field).float.(float_abs_range_proto2) = 1.0]; +} + +message PredefinedDoubleRuleProto2 { + optional double val = 1 [(buf.validate.field).double.(double_abs_range_proto2) = 1.0]; +} + +message PredefinedInt32RuleProto2 { + optional int32 val = 1 [(buf.validate.field).int32.(int32_abs_in_proto2) = -2]; +} + +message PredefinedInt64RuleProto2 { + optional int64 val = 1 [(buf.validate.field).int64.(int64_abs_in_proto2) = {value: -2}]; +} + +message PredefinedUInt32RuleProto2 { + optional uint32 val = 1 [(buf.validate.field).uint32.(uint32_even_proto2) = true]; +} + +message PredefinedUInt64RuleProto2 { + optional uint64 val = 1 [(buf.validate.field).uint64.(uint64_even_proto2) = true]; +} + +message PredefinedSInt32RuleProto2 { + optional sint32 val = 1 [(buf.validate.field).sint32.(sint32_even_proto2) = true]; +} + +message PredefinedSInt64RuleProto2 { + optional sint64 val = 1 [(buf.validate.field).sint64.(sint64_even_proto2) = true]; +} + +message PredefinedFixed32RuleProto2 { + optional fixed32 val = 1 [(buf.validate.field).fixed32.(fixed32_even_proto2) = true]; +} + +message PredefinedFixed64RuleProto2 { + optional fixed64 val = 1 [(buf.validate.field).fixed64.(fixed64_even_proto2) = true]; +} + +message PredefinedSFixed32RuleProto2 { + optional sfixed32 val = 1 [(buf.validate.field).sfixed32.(sfixed32_even_proto2) = true]; +} + +message PredefinedSFixed64RuleProto2 { + optional sfixed64 val = 1 [(buf.validate.field).sfixed64.(sfixed64_even_proto2) = true]; +} + +message PredefinedBoolRuleProto2 { + optional bool val = 1 [(buf.validate.field).bool.(bool_false_proto2) = true]; +} + +message PredefinedStringRuleProto2 { + optional string val = 1 [(buf.validate.field).string.(string_valid_path_proto2) = true]; +} + +message PredefinedBytesRuleProto2 { + optional bytes val = 1 [(buf.validate.field).bytes.(bytes_valid_path_proto2) = true]; +} + +message PredefinedEnumRuleProto2 { + enum EnumProto2 { + ENUM_PROTO2_ZERO_UNSPECIFIED = 0; + ENUM_PROTO2_ONE = 1; + } + optional EnumProto2 val = 1 [(buf.validate.field).enum.(enum_non_zero_proto2) = true]; +} + +message PredefinedRepeatedRuleProto2 { + repeated uint64 val = 1 [(buf.validate.field).repeated.(repeated_at_least_five_proto2) = true]; +} + +message PredefinedDurationRuleProto2 { + optional google.protobuf.Duration val = 1 [(buf.validate.field).duration.(duration_too_long_proto2) = true]; +} + +message PredefinedTimestampRuleProto2 { + optional google.protobuf.Timestamp val = 1 [(buf.validate.field).timestamp.(timestamp_in_range_proto2) = true]; +} + +message PredefinedWrappedFloatRuleProto2 { + optional google.protobuf.FloatValue val = 1 [(buf.validate.field).float.(float_abs_range_proto2) = 1.0]; +} + +message PredefinedWrappedDoubleRuleProto2 { + optional google.protobuf.DoubleValue val = 1 [(buf.validate.field).double.(double_abs_range_proto2) = 1.0]; +} + +message PredefinedWrappedInt32RuleProto2 { + optional google.protobuf.Int32Value val = 1 [(buf.validate.field).int32.(int32_abs_in_proto2) = -2]; +} + +message PredefinedWrappedInt64RuleProto2 { + optional google.protobuf.Int64Value val = 1 [(buf.validate.field).int64.(int64_abs_in_proto2) = {value: -2}]; +} + +message PredefinedWrappedUInt32RuleProto2 { + optional google.protobuf.UInt32Value val = 1 [(buf.validate.field).uint32.(uint32_even_proto2) = true]; +} + +message PredefinedWrappedUInt64RuleProto2 { + optional google.protobuf.UInt64Value val = 1 [(buf.validate.field).uint64.(uint64_even_proto2) = true]; +} + +message PredefinedWrappedBoolRuleProto2 { + optional google.protobuf.BoolValue val = 1 [(buf.validate.field).bool.(bool_false_proto2) = true]; +} + +message PredefinedWrappedStringRuleProto2 { + optional google.protobuf.StringValue val = 1 [(buf.validate.field).string.(string_valid_path_proto2) = true]; +} + +message PredefinedWrappedBytesRuleProto2 { + optional google.protobuf.BytesValue val = 1 [(buf.validate.field).bytes.(bytes_valid_path_proto2) = true]; +} + +message PredefinedRepeatedWrappedFloatRuleProto2 { + repeated google.protobuf.FloatValue val = 1 [(buf.validate.field).repeated.items.float.(float_abs_range_proto2) = 1.0]; +} + +message PredefinedRepeatedWrappedDoubleRuleProto2 { + repeated google.protobuf.DoubleValue val = 1 [(buf.validate.field).repeated.items.double.(double_abs_range_proto2) = 1.0]; +} + +message PredefinedRepeatedWrappedInt32RuleProto2 { + repeated google.protobuf.Int32Value val = 1 [(buf.validate.field).repeated.items.int32.(int32_abs_in_proto2) = -2]; +} + +message PredefinedRepeatedWrappedInt64RuleProto2 { + repeated google.protobuf.Int64Value val = 1 [(buf.validate.field).repeated.items.int64.(int64_abs_in_proto2) = {value: -2}]; +} + +message PredefinedRepeatedWrappedUInt32RuleProto2 { + repeated google.protobuf.UInt32Value val = 1 [(buf.validate.field).repeated.items.uint32.(uint32_even_proto2) = true]; +} + +message PredefinedRepeatedWrappedUInt64RuleProto2 { + repeated google.protobuf.UInt64Value val = 1 [(buf.validate.field).repeated.items.uint64.(uint64_even_proto2) = true]; +} + +message PredefinedRepeatedWrappedBoolRuleProto2 { + repeated google.protobuf.BoolValue val = 1 [(buf.validate.field).repeated.items.bool.(bool_false_proto2) = true]; +} + +message PredefinedRepeatedWrappedStringRuleProto2 { + repeated google.protobuf.StringValue val = 1 [(buf.validate.field).repeated.items.string.(string_valid_path_proto2) = true]; +} + +message PredefinedRepeatedWrappedBytesRuleProto2 { + repeated google.protobuf.BytesValue val = 1 [(buf.validate.field).repeated.items.bytes.(bytes_valid_path_proto2) = true]; +} + +message PredefinedAndCustomRuleProto2 { + optional sint32 a = 1 [ + (field).cel = { + id: "predefined_and_custom_rule_scalar_proto2" + expression: "this > 24 ? '' : 'a must be greater than 24'" + }, + (field).sint32.(sint32_even_proto2) = true + ]; + + optional Nested b = 2 [(field).cel = { + id: "predefined_and_custom_rule_embedded_proto2" + message: "b.c must be a multiple of 3" + expression: "this.c % 3 == 0" + }]; + + message Nested { + optional sint32 c = 1 [ + (field).cel = { + id: "predefined_and_custom_rule_nested_proto2" + expression: "this > 0 ? '' : 'c must be positive'" + }, + (field).sint32.(sint32_even_proto2) = true + ]; + } +} + +message StandardPredefinedAndCustomRuleProto2 { + optional sint32 a = 1 [ + (field).sint32.lt = 28, + (field).sint32.(sint32_even_proto2) = true, + (field).cel = { + id: "standard_predefined_and_custom_rule_scalar_proto2" + expression: "this > 24 ? '' : 'a must be greater than 24'" + } + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/state.json b/modules/sync/bufbuild/protovalidate-testing/state.json index 88a5fa51..4c2b346e 100644 --- a/modules/sync/bufbuild/protovalidate-testing/state.json +++ b/modules/sync/bufbuild/protovalidate-testing/state.json @@ -267,6 +267,10 @@ { "name": "v1.1.0", "digest": "afa300ba05b84e201fe0bc66b0927254e8097afe00fdc4ef7587fcb112c3f76dcd7550c58e6f8d513b1231e2a67adfd31abb2fbcb13f8e99e42e78b541b6dd20" + }, + { + "name": "v1.1.1", + "digest": "46ea994e1a721a88047c54bfbb7fd9696cb51df07c03745828a8616381151a1ecc7e4fb734cb19257e1d1beaf4072a3ca404393bb2719bb7e1846773acb06a36" } ] } \ No newline at end of file diff --git a/modules/sync/bufbuild/protovalidate/cas/2751dd35f02933b1ae7a0394896014c1506c8aa3a737d3f65c81fb67f6332626db630c1c9291a579bb8b60d1eccd35064e19dffdbffd033dd0144bd228861503 b/modules/sync/bufbuild/protovalidate/cas/2751dd35f02933b1ae7a0394896014c1506c8aa3a737d3f65c81fb67f6332626db630c1c9291a579bb8b60d1eccd35064e19dffdbffd033dd0144bd228861503 new file mode 100644 index 00000000..f0371d39 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate/cas/2751dd35f02933b1ae7a0394896014c1506c8aa3a737d3f65c81fb67f6332626db630c1c9291a579bb8b60d1eccd35064e19dffdbffd033dd0144bd228861503 @@ -0,0 +1,5057 @@ +// Copyright 2023-2026 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"; + +// [Protovalidate](https://protovalidate.com/) is the semantic validation library for Protobuf. +// It provides standard annotations to validate common rules on messages and fields, as well as the ability to use [CEL](https://cel.dev) to write custom rules. +// It's the next generation of [protoc-gen-validate](https://github.com/bufbuild/protoc-gen-validate). +// +// This package provides the options, messages, and enums that power Protovalidate. +// Apply its options to messages, fields, and oneofs in your Protobuf schemas to add validation rules: +// +// ```proto +// message User { +// string id = 1 [(buf.validate.field).string.uuid = true]; +// string first_name = 2 [(buf.validate.field).string.max_len = 64]; +// string last_name = 3 [(buf.validate.field).string.max_len = 64]; +// +// option (buf.validate.message).cel = { +// id: "first_name_requires_last_name" +// message: "last_name must be present if first_name is present" +// expression: "!has(this.first_name) || has(this.last_name)" +// }; +// } +// ``` +// +// These rules are enforced at runtime by language-specific libraries. +// See the [developer quickstart](https://protovalidate.com/quickstart/) to get started, or go directly to the runtime library for your language: +// [Go](https://github.com/bufbuild/protovalidate-go) +// [JavaScript/TypeScript](https://github.com/bufbuild/protovalidate-es), +// [Java](https://github.com/bufbuild/protovalidate-java), +// [Python](https://github.com/bufbuild/protovalidate-python), +// or [C++](https://github.com/bufbuild/protovalidate-cc). +package buf.validate; + +import "google/protobuf/descriptor.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"; +option java_multiple_files = true; +option java_outer_classname = "ValidateProto"; +option java_package = "build.buf.validate"; + +// MessageOptions is an extension to google.protobuf.MessageOptions. It allows +// the addition of validation rules at the message level. These rules can be +// applied to incoming messages to ensure they meet certain criteria before +// being processed. +extend google.protobuf.MessageOptions { + // Rules specify the validations to be performed on this message. By default, + // no validation is performed against a message. + optional MessageRules message = 1159; +} + +// OneofOptions is an extension to google.protobuf.OneofOptions. It allows +// the addition of validation rules on a oneof. These rules can be +// applied to incoming messages to ensure they meet certain criteria before +// being processed. +extend google.protobuf.OneofOptions { + // Rules specify the validations to be performed on this oneof. By default, + // no validation is performed against a oneof. + optional OneofRules oneof = 1159; +} + +// FieldOptions is an extension to google.protobuf.FieldOptions. It allows +// the addition of validation rules at the field level. These rules can be +// applied to incoming messages to ensure they meet certain criteria before +// being processed. +extend google.protobuf.FieldOptions { + // Rules specify the validations to be performed on this field. By default, + // no validation is performed against a field. + optional FieldRules field = 1159; + + // Specifies predefined rules. When extending a standard rule message, + // this adds additional CEL expressions that apply when the extension is used. + // + // ```proto + // extend buf.validate.Int32Rules { + // bool is_zero [(buf.validate.predefined).cel = { + // id: "int32.is_zero", + // message: "value must be zero", + // expression: "!rule || this == 0", + // }]; + // } + // + // message Foo { + // int32 reserved = 1 [(buf.validate.field).int32.(is_zero) = true]; + // } + // ``` + optional PredefinedRules predefined = 1160; +} + +// `Rule` represents a validation rule written in the Common Expression +// Language (CEL) syntax. Each Rule includes a unique identifier, an +// optional error message, and the CEL expression to evaluate. For more +// information, [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/). +// +// ```proto +// message Foo { +// option (buf.validate.message).cel = { +// id: "foo.bar" +// message: "bar must be greater than 0" +// expression: "this.bar > 0" +// }; +// int32 bar = 1; +// } +// ``` +message Rule { + // `id` is a string that serves as a machine-readable name for this Rule. + // It should be unique within its scope, which could be either a message or a field. + optional string id = 1; + + // `message` is an optional field that provides a human-readable error message + // for this Rule when the CEL expression evaluates to false. If a + // non-empty message is provided, any strings resulting from the CEL + // expression evaluation are ignored. + optional string message = 2; + + // `expression` is the actual CEL expression that will be evaluated for + // validation. This string must resolve to either a boolean or a string + // value. If the expression evaluates to false or a non-empty string, the + // validation is considered failed, and the message is rejected. + optional string expression = 3; +} + +// MessageRules represents validation rules that are applied to the entire message. +// It includes disabling options and a list of Rule messages representing Common Expression Language (CEL) validation rules. +message MessageRules { + // `cel_expression` is a repeated field CEL expressions. Each expression specifies a validation + // rule to be applied to this message. These rules are written in Common Expression Language (CEL) syntax. + // + // This is a simplified form of the `cel` Rule field, where only `expression` is set. This allows for + // simpler syntax when defining CEL Rules where `id` and `message` derived from the `expression`. `id` will + // be same as the `expression`. + // + // For more information, [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/). + // + // ```proto + // message MyMessage { + // // The field `foo` must be greater than 42. + // option (buf.validate.message).cel_expression = "this.foo > 42"; + // // The field `foo` must be less than 84. + // option (buf.validate.message).cel_expression = "this.foo < 84"; + // optional int32 foo = 1; + // } + // ``` + repeated string cel_expression = 5; + // `cel` is a repeated field of type Rule. Each Rule specifies a validation rule to be applied to this message. + // These rules are written in Common Expression Language (CEL) syntax. For more information, + // [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/). + // + // + // ```proto + // message MyMessage { + // // The field `foo` must be greater than 42. + // option (buf.validate.message).cel = { + // id: "my_message.value", + // message: "value must be greater than 42", + // expression: "this.foo > 42", + // }; + // optional int32 foo = 1; + // } + // ``` + repeated Rule cel = 3; + + // `oneof` is a repeated field of type MessageOneofRule that specifies a list of fields + // of which at most one can be present. If `required` is also specified, then exactly one + // of the specified fields _must_ be present. + // + // This will enforce oneof-like constraints with a few features not provided by + // actual Protobuf oneof declarations: + // 1. Repeated and map fields are allowed in this validation. In a Protobuf oneof, + // only scalar fields are allowed. + // 2. Fields with implicit presence are allowed. In a Protobuf oneof, all member + // fields have explicit presence. This means that, for the purpose of determining + // how many fields are set, explicitly setting such a field to its zero value is + // effectively the same as not setting it at all. + // 3. This will always generate validation errors for a message unmarshalled from + // serialized data that sets more than one field. With a Protobuf oneof, when + // multiple fields are present in the serialized form, earlier values are usually + // silently ignored when unmarshalling, with only the last field being set when + // unmarshalling completes. + // + // Note that adding a field to a `oneof` will also set the IGNORE_IF_ZERO_VALUE on the fields. This means + // only the field that is set will be validated and the unset fields are not validated according to the field rules. + // This behavior can be overridden by setting `ignore` against a field. + // + // ```proto + // message MyMessage { + // // Only one of `field1` or `field2` _can_ be present in this message. + // option (buf.validate.message).oneof = { fields: ["field1", "field2"] }; + // // Exactly one of `field3` or `field4` _must_ be present in this message. + // option (buf.validate.message).oneof = { fields: ["field3", "field4"], required: true }; + // string field1 = 1; + // bytes field2 = 2; + // bool field3 = 3; + // int32 field4 = 4; + // } + // ``` + repeated MessageOneofRule oneof = 4; + + reserved 1; + reserved "disabled"; +} + +message MessageOneofRule { + // A list of field names to include in the oneof. All field names must be + // defined in the message. At least one field must be specified, and + // duplicates are not permitted. + repeated string fields = 1; + // If true, one of the fields specified _must_ be set. + optional bool required = 2; +} + +// The `OneofRules` message type enables you to manage rules for +// oneof fields in your protobuf messages. +message OneofRules { + // If `required` is true, exactly one field of the oneof must be set. A + // validation error is returned if no fields in the oneof are set. Further rules + // should be placed on the fields themselves to ensure they are valid values, + // such as `min_len` or `gt`. + // + // ```proto + // message MyMessage { + // oneof value { + // // 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; + // string a = 1 [(buf.validate.field).string.min_len = 1]; + // string b = 2; + // } + // } + // ``` + optional bool required = 1; +} + +// FieldRules encapsulates the rules for each type of field. Depending on +// the field, the correct set should be used to ensure proper validations. +message FieldRules { + // `cel_expression` is a repeated field CEL expressions. Each expression specifies a validation + // rule to be applied to this message. These rules are written in Common Expression Language (CEL) syntax. + // + // This is a simplified form of the `cel` Rule field, where only `expression` is set. This allows for + // simpler syntax when defining CEL Rules where `id` and `message` derived from the `expression`. `id` will + // be same as the `expression`. + // + // For more information, [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/). + // + // ```proto + // message MyMessage { + // // The field `value` must be greater than 42. + // optional int32 value = 1 [(buf.validate.field).cel_expression = "this > 42"]; + // } + // ``` + repeated string cel_expression = 29; + // `cel` is a repeated field used to represent a textual expression + // in the Common Expression Language (CEL) syntax. For more information, + // [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/). + // + // ```proto + // message MyMessage { + // // The field `value` must be greater than 42. + // optional int32 value = 1 [(buf.validate.field).cel = { + // id: "my_message.value", + // message: "value must be greater than 42", + // expression: "this > 42", + // }]; + // } + // ``` + repeated Rule cel = 23; + // If `required` is true, the field must be set. A validation error is returned + // if the field is not set. + // + // ```proto + // syntax="proto3"; + // + // message FieldsWithPresence { + // // Requires any string to be set, including the empty string. + // optional string link = 1 [ + // (buf.validate.field).required = true + // ]; + // // Requires true or false to be set. + // optional bool disabled = 2 [ + // (buf.validate.field).required = true + // ]; + // // Requires a message to be set, including the empty message. + // SomeMessage msg = 4 [ + // (buf.validate.field).required = true + // ]; + // } + // ``` + // + // All fields in the example above track presence. By default, Protovalidate + // ignores rules on those fields if no value is set. `required` ensures that + // the fields are set and valid. + // + // Fields that don't track presence are always validated by Protovalidate, + // whether they are set or not. It is not necessary to add `required`. It + // can be added to indicate that the field cannot be the zero value. + // + // ```proto + // syntax="proto3"; + // + // message FieldsWithoutPresence { + // // `string.email` always applies, even to an empty string. + // string link = 1 [ + // (buf.validate.field).string.email = true + // ]; + // // `repeated.min_items` always applies, even to an empty list. + // repeated string labels = 2 [ + // (buf.validate.field).repeated.min_items = 1 + // ]; + // // `required`, for fields that don't track presence, indicates + // // the value of the field can't be the zero value. + // int32 zero_value_not_allowed = 3 [ + // (buf.validate.field).required = true + // ]; + // } + // ``` + // + // To learn which fields track presence, see the + // [Field Presence cheat sheet](https://protobuf.dev/programming-guides/field_presence/#cheat). + // + // Note: While field rules can be applied to repeated items, map keys, and map + // values, the elements are always considered to be set. Consequently, + // specifying `repeated.items.required` is redundant. + optional bool required = 25; + // Ignore validation rules on the field if its value matches the specified + // criteria. See the `Ignore` enum for details. + // + // ```proto + // message UpdateRequest { + // // The uri rule only applies if the field is not an empty string. + // string url = 1 [ + // (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + // (buf.validate.field).string.uri = true + // ]; + // } + // ``` + optional Ignore ignore = 27; + + oneof type { + // Scalar Field Types + FloatRules float = 1; + DoubleRules double = 2; + Int32Rules int32 = 3; + Int64Rules int64 = 4; + UInt32Rules uint32 = 5; + UInt64Rules uint64 = 6; + SInt32Rules sint32 = 7; + SInt64Rules sint64 = 8; + Fixed32Rules fixed32 = 9; + Fixed64Rules fixed64 = 10; + SFixed32Rules sfixed32 = 11; + SFixed64Rules sfixed64 = 12; + BoolRules bool = 13; + StringRules string = 14; + BytesRules bytes = 15; + + // Complex Field Types + EnumRules enum = 16; + RepeatedRules repeated = 18; + MapRules map = 19; + + // Well-Known Field Types + AnyRules any = 20; + DurationRules duration = 21; + FieldMaskRules field_mask = 28; + TimestampRules timestamp = 22; + } + + reserved 24, 26; + reserved "skipped", "ignore_empty"; +} + +// PredefinedRules are custom rules that can be re-used with +// multiple fields. +message PredefinedRules { + // `cel` is a repeated field used to represent a textual expression + // in the Common Expression Language (CEL) syntax. For more information, + // [see our documentation](https://buf.build/docs/protovalidate/schemas/predefined-rules/). + // + // ```proto + // message MyMessage { + // // The field `value` must be greater than 42. + // optional int32 value = 1 [(buf.validate.predefined).cel = { + // id: "my_message.value", + // message: "value must be greater than 42", + // expression: "this > 42", + // }]; + // } + // ``` + repeated Rule cel = 1; + + reserved 24, 26; + reserved "skipped", "ignore_empty"; +} + +// Specifies how `FieldRules.ignore` behaves, depending on the field's value, and +// whether the field tracks presence. +enum Ignore { + // Ignore rules if the field tracks presence and is unset. This is the default + // behavior. + // + // In proto3, only message fields, members of a Protobuf `oneof`, and fields + // with the `optional` label track presence. Consequently, the following fields + // are always validated, whether a value is set or not: + // + // ```proto + // syntax="proto3"; + // + // message RulesApply { + // string email = 1 [ + // (buf.validate.field).string.email = true + // ]; + // int32 age = 2 [ + // (buf.validate.field).int32.gt = 0 + // ]; + // repeated string labels = 3 [ + // (buf.validate.field).repeated.min_items = 1 + // ]; + // } + // ``` + // + // In contrast, the following fields track presence, and are only validated if + // a value is set: + // + // ```proto + // syntax="proto3"; + // + // message RulesApplyIfSet { + // optional string email = 1 [ + // (buf.validate.field).string.email = true + // ]; + // oneof ref { + // string reference = 2 [ + // (buf.validate.field).string.uuid = true + // ]; + // string name = 3 [ + // (buf.validate.field).string.min_len = 4 + // ]; + // } + // SomeMessage msg = 4 [ + // (buf.validate.field).cel = {/* ... */} + // ]; + // } + // ``` + // + // To ensure that such a field is set, add the `required` rule. + // + // To learn which fields track presence, see the + // [Field Presence cheat sheet](https://protobuf.dev/programming-guides/field_presence/#cheat). + IGNORE_UNSPECIFIED = 0; + + // Ignore rules if the field is unset, or set to the zero value. + // + // The zero value depends on the field type: + // - For strings, the zero value is the empty string. + // - For bytes, the zero value is empty bytes. + // - For bool, the zero value is false. + // - For numeric types, the zero value is zero. + // - For enums, the zero value is the first defined enum value. + // - For repeated fields, the zero is an empty list. + // - For map fields, the zero is an empty map. + // - For message fields, absence of the message (typically a null-value) is considered zero value. + // + // For fields that track presence (e.g. adding the `optional` label in proto3), + // this a no-op and behavior is the same as the default `IGNORE_UNSPECIFIED`. + IGNORE_IF_ZERO_VALUE = 1; + + // Always ignore rules, including the `required` rule. + // + // This is useful for ignoring the rules of a referenced message, or to + // temporarily ignore rules during development. + // + // ```proto + // message MyMessage { + // // The field's rules will always be ignored, including any validations + // // on value's fields. + // MyOtherMessage value = 1 [ + // (buf.validate.field).ignore = IGNORE_ALWAYS + // ]; + // } + // ``` + IGNORE_ALWAYS = 3; + + reserved 2; + reserved "IGNORE_EMPTY", "IGNORE_DEFAULT", "IGNORE_IF_DEFAULT_VALUE", "IGNORE_IF_UNPOPULATED"; +} + +// FloatRules describes the rules applied to `float` values. These +// rules may also be applied to the `google.protobuf.FloatValue` Well-Known-Type. +message FloatRules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyFloat { + // // value must equal 42.0 + // float value = 1 [(buf.validate.field).float.const = 42.0]; + // } + // ``` + optional float const = 1 [(predefined).cel = { + id: "float.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyFloat { + // // value must be less than 10.0 + // float value = 1 [(buf.validate.field).float.lt = 10.0]; + // } + // ``` + float lt = 2 [(predefined).cel = { + id: "float.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyFloat { + // // value must be less than or equal to 10.0 + // float value = 1 [(buf.validate.field).float.lte = 10.0]; + // } + // ``` + float lte = 3 [(predefined).cel = { + id: "float.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFloat { + // // value must be greater than 5.0 [float.gt] + // float value = 1 [(buf.validate.field).float.gt = 5.0]; + // + // // value must be greater than 5 and less than 10.0 [float.gt_lt] + // float other_value = 2 [(buf.validate.field).float = { gt: 5.0, lt: 10.0 }]; + // + // // value must be greater than 10 or less than 5.0 [float.gt_lt_exclusive] + // float another_value = 3 [(buf.validate.field).float = { gt: 10.0, lt: 5.0 }]; + // } + // ``` + float gt = 4 [ + (predefined).cel = { + id: "float.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "float.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "float.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "float.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "float.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFloat { + // // value must be greater than or equal to 5.0 [float.gte] + // float value = 1 [(buf.validate.field).float.gte = 5.0]; + // + // // value must be greater than or equal to 5.0 and less than 10.0 [float.gte_lt] + // float other_value = 2 [(buf.validate.field).float = { gte: 5.0, lt: 10.0 }]; + // + // // value must be greater than or equal to 10.0 or less than 5.0 [float.gte_lt_exclusive] + // float another_value = 3 [(buf.validate.field).float = { gte: 10.0, lt: 5.0 }]; + // } + // ``` + float gte = 5 [ + (predefined).cel = { + id: "float.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "float.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "float.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "float.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "float.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message + // is generated. + // + // ```proto + // message MyFloat { + // // value must be in list [1.0, 2.0, 3.0] + // float value = 1 [(buf.validate.field).float = { in: [1.0, 2.0, 3.0] }]; + // } + // ``` + repeated float in = 6 [(predefined).cel = { + id: "float.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyFloat { + // // value must not be in list [1.0, 2.0, 3.0] + // float value = 1 [(buf.validate.field).float = { not_in: [1.0, 2.0, 3.0] }]; + // } + // ``` + repeated float not_in = 7 [(predefined).cel = { + id: "float.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `finite` requires the field value to be finite. If the field value is + // infinite or NaN, an error message is generated. + optional bool finite = 8 [(predefined).cel = { + id: "float.finite" + expression: "rules.finite ? (this.isNan() || this.isInf() ? 'value must be finite' : '') : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyFloat { + // float value = 1 [ + // (buf.validate.field).float.example = 1.0, + // (buf.validate.field).float.example = inf + // ]; + // } + // ``` + repeated float example = 9 [(predefined).cel = { + id: "float.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// DoubleRules describes the rules applied to `double` values. These +// rules may also be applied to the `google.protobuf.DoubleValue` Well-Known-Type. +message DoubleRules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyDouble { + // // value must equal 42.0 + // double value = 1 [(buf.validate.field).double.const = 42.0]; + // } + // ``` + optional double const = 1 [(predefined).cel = { + id: "double.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyDouble { + // // value must be less than 10.0 + // double value = 1 [(buf.validate.field).double.lt = 10.0]; + // } + // ``` + double lt = 2 [(predefined).cel = { + id: "double.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified value + // (field <= value). If the field value is greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyDouble { + // // value must be less than or equal to 10.0 + // double value = 1 [(buf.validate.field).double.lte = 10.0]; + // } + // ``` + double lte = 3 [(predefined).cel = { + id: "double.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or `lte`, + // the range is reversed, and the field value must be outside the specified + // range. If the field value doesn't meet the required conditions, an error + // message is generated. + // + // ```proto + // message MyDouble { + // // value must be greater than 5.0 [double.gt] + // double value = 1 [(buf.validate.field).double.gt = 5.0]; + // + // // value must be greater than 5 and less than 10.0 [double.gt_lt] + // double other_value = 2 [(buf.validate.field).double = { gt: 5.0, lt: 10.0 }]; + // + // // value must be greater than 10 or less than 5.0 [double.gt_lt_exclusive] + // double another_value = 3 [(buf.validate.field).double = { gt: 10.0, lt: 5.0 }]; + // } + // ``` + double gt = 4 [ + (predefined).cel = { + id: "double.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "double.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "double.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "double.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "double.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyDouble { + // // value must be greater than or equal to 5.0 [double.gte] + // double value = 1 [(buf.validate.field).double.gte = 5.0]; + // + // // value must be greater than or equal to 5.0 and less than 10.0 [double.gte_lt] + // double other_value = 2 [(buf.validate.field).double = { gte: 5.0, lt: 10.0 }]; + // + // // value must be greater than or equal to 10.0 or less than 5.0 [double.gte_lt_exclusive] + // double another_value = 3 [(buf.validate.field).double = { gte: 10.0, lt: 5.0 }]; + // } + // ``` + double gte = 5 [ + (predefined).cel = { + id: "double.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "double.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "double.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "double.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "double.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyDouble { + // // value must be in list [1.0, 2.0, 3.0] + // double value = 1 [(buf.validate.field).double = { in: [1.0, 2.0, 3.0] }]; + // } + // ``` + repeated double in = 6 [(predefined).cel = { + id: "double.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyDouble { + // // value must not be in list [1.0, 2.0, 3.0] + // double value = 1 [(buf.validate.field).double = { not_in: [1.0, 2.0, 3.0] }]; + // } + // ``` + repeated double not_in = 7 [(predefined).cel = { + id: "double.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `finite` requires the field value to be finite. If the field value is + // infinite or NaN, an error message is generated. + optional bool finite = 8 [(predefined).cel = { + id: "double.finite" + expression: "rules.finite ? (this.isNan() || this.isInf() ? 'value must be finite' : '') : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyDouble { + // double value = 1 [ + // (buf.validate.field).double.example = 1.0, + // (buf.validate.field).double.example = inf + // ]; + // } + // ``` + repeated double example = 9 [(predefined).cel = { + id: "double.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// Int32Rules describes the rules applied to `int32` values. These +// rules may also be applied to the `google.protobuf.Int32Value` Well-Known-Type. +message Int32Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must equal 42 + // int32 value = 1 [(buf.validate.field).int32.const = 42]; + // } + // ``` + optional int32 const = 1 [(predefined).cel = { + id: "int32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field + // < value). If the field value is equal to or greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must be less than 10 + // int32 value = 1 [(buf.validate.field).int32.lt = 10]; + // } + // ``` + int32 lt = 2 [(predefined).cel = { + id: "int32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must be less than or equal to 10 + // int32 value = 1 [(buf.validate.field).int32.lte = 10]; + // } + // ``` + int32 lte = 3 [(predefined).cel = { + id: "int32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must be greater than 5 [int32.gt] + // int32 value = 1 [(buf.validate.field).int32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [int32.gt_lt] + // int32 other_value = 2 [(buf.validate.field).int32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [int32.gt_lt_exclusive] + // int32 another_value = 3 [(buf.validate.field).int32 = { gt: 10, lt: 5 }]; + // } + // ``` + int32 gt = 4 [ + (predefined).cel = { + id: "int32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "int32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "int32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified value + // (exclusive). If the value of `gte` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must be greater than or equal to 5 [int32.gte] + // int32 value = 1 [(buf.validate.field).int32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [int32.gte_lt] + // int32 other_value = 2 [(buf.validate.field).int32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [int32.gte_lt_exclusive] + // int32 another_value = 3 [(buf.validate.field).int32 = { gte: 10, lt: 5 }]; + // } + // ``` + int32 gte = 5 [ + (predefined).cel = { + id: "int32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "int32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "int32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyInt32 { + // // value must be in list [1, 2, 3] + // int32 value = 1 [(buf.validate.field).int32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated int32 in = 6 [(predefined).cel = { + id: "int32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error message + // is generated. + // + // ```proto + // message MyInt32 { + // // value must not be in list [1, 2, 3] + // int32 value = 1 [(buf.validate.field).int32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated int32 not_in = 7 [(predefined).cel = { + id: "int32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyInt32 { + // int32 value = 1 [ + // (buf.validate.field).int32.example = 1, + // (buf.validate.field).int32.example = -10 + // ]; + // } + // ``` + repeated int32 example = 8 [(predefined).cel = { + id: "int32.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// Int64Rules describes the rules applied to `int64` values. These +// rules may also be applied to the `google.protobuf.Int64Value` Well-Known-Type. +message Int64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must equal 42 + // int64 value = 1 [(buf.validate.field).int64.const = 42]; + // } + // ``` + optional int64 const = 1 [(predefined).cel = { + id: "int64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must be less than 10 + // int64 value = 1 [(buf.validate.field).int64.lt = 10]; + // } + // ``` + int64 lt = 2 [(predefined).cel = { + id: "int64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must be less than or equal to 10 + // int64 value = 1 [(buf.validate.field).int64.lte = 10]; + // } + // ``` + int64 lte = 3 [(predefined).cel = { + id: "int64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must be greater than 5 [int64.gt] + // int64 value = 1 [(buf.validate.field).int64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [int64.gt_lt] + // int64 other_value = 2 [(buf.validate.field).int64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [int64.gt_lt_exclusive] + // int64 another_value = 3 [(buf.validate.field).int64 = { gt: 10, lt: 5 }]; + // } + // ``` + int64 gt = 4 [ + (predefined).cel = { + id: "int64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "int64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "int64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must be greater than or equal to 5 [int64.gte] + // int64 value = 1 [(buf.validate.field).int64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [int64.gte_lt] + // int64 other_value = 2 [(buf.validate.field).int64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [int64.gte_lt_exclusive] + // int64 another_value = 3 [(buf.validate.field).int64 = { gte: 10, lt: 5 }]; + // } + // ``` + int64 gte = 5 [ + (predefined).cel = { + id: "int64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "int64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "int64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyInt64 { + // // value must be in list [1, 2, 3] + // int64 value = 1 [(buf.validate.field).int64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated int64 in = 6 [(predefined).cel = { + id: "int64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyInt64 { + // // value must not be in list [1, 2, 3] + // int64 value = 1 [(buf.validate.field).int64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated int64 not_in = 7 [(predefined).cel = { + id: "int64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyInt64 { + // int64 value = 1 [ + // (buf.validate.field).int64.example = 1, + // (buf.validate.field).int64.example = -10 + // ]; + // } + // ``` + repeated int64 example = 9 [(predefined).cel = { + id: "int64.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// UInt32Rules describes the rules applied to `uint32` values. These +// rules may also be applied to the `google.protobuf.UInt32Value` Well-Known-Type. +message UInt32Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must equal 42 + // uint32 value = 1 [(buf.validate.field).uint32.const = 42]; + // } + // ``` + optional uint32 const = 1 [(predefined).cel = { + id: "uint32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must be less than 10 + // uint32 value = 1 [(buf.validate.field).uint32.lt = 10]; + // } + // ``` + uint32 lt = 2 [(predefined).cel = { + id: "uint32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must be less than or equal to 10 + // uint32 value = 1 [(buf.validate.field).uint32.lte = 10]; + // } + // ``` + uint32 lte = 3 [(predefined).cel = { + id: "uint32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must be greater than 5 [uint32.gt] + // uint32 value = 1 [(buf.validate.field).uint32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [uint32.gt_lt] + // uint32 other_value = 2 [(buf.validate.field).uint32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [uint32.gt_lt_exclusive] + // uint32 another_value = 3 [(buf.validate.field).uint32 = { gt: 10, lt: 5 }]; + // } + // ``` + uint32 gt = 4 [ + (predefined).cel = { + id: "uint32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "uint32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "uint32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must be greater than or equal to 5 [uint32.gte] + // uint32 value = 1 [(buf.validate.field).uint32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [uint32.gte_lt] + // uint32 other_value = 2 [(buf.validate.field).uint32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [uint32.gte_lt_exclusive] + // uint32 another_value = 3 [(buf.validate.field).uint32 = { gte: 10, lt: 5 }]; + // } + // ``` + uint32 gte = 5 [ + (predefined).cel = { + id: "uint32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "uint32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "uint32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyUInt32 { + // // value must be in list [1, 2, 3] + // uint32 value = 1 [(buf.validate.field).uint32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated uint32 in = 6 [(predefined).cel = { + id: "uint32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyUInt32 { + // // value must not be in list [1, 2, 3] + // uint32 value = 1 [(buf.validate.field).uint32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated uint32 not_in = 7 [(predefined).cel = { + id: "uint32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyUInt32 { + // uint32 value = 1 [ + // (buf.validate.field).uint32.example = 1, + // (buf.validate.field).uint32.example = 10 + // ]; + // } + // ``` + repeated uint32 example = 8 [(predefined).cel = { + id: "uint32.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// UInt64Rules describes the rules applied to `uint64` values. These +// rules may also be applied to the `google.protobuf.UInt64Value` Well-Known-Type. +message UInt64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must equal 42 + // uint64 value = 1 [(buf.validate.field).uint64.const = 42]; + // } + // ``` + optional uint64 const = 1 [(predefined).cel = { + id: "uint64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must be less than 10 + // uint64 value = 1 [(buf.validate.field).uint64.lt = 10]; + // } + // ``` + uint64 lt = 2 [(predefined).cel = { + id: "uint64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must be less than or equal to 10 + // uint64 value = 1 [(buf.validate.field).uint64.lte = 10]; + // } + // ``` + uint64 lte = 3 [(predefined).cel = { + id: "uint64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must be greater than 5 [uint64.gt] + // uint64 value = 1 [(buf.validate.field).uint64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [uint64.gt_lt] + // uint64 other_value = 2 [(buf.validate.field).uint64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [uint64.gt_lt_exclusive] + // uint64 another_value = 3 [(buf.validate.field).uint64 = { gt: 10, lt: 5 }]; + // } + // ``` + uint64 gt = 4 [ + (predefined).cel = { + id: "uint64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "uint64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "uint64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must be greater than or equal to 5 [uint64.gte] + // uint64 value = 1 [(buf.validate.field).uint64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [uint64.gte_lt] + // uint64 other_value = 2 [(buf.validate.field).uint64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [uint64.gte_lt_exclusive] + // uint64 another_value = 3 [(buf.validate.field).uint64 = { gte: 10, lt: 5 }]; + // } + // ``` + uint64 gte = 5 [ + (predefined).cel = { + id: "uint64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "uint64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "uint64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyUInt64 { + // // value must be in list [1, 2, 3] + // uint64 value = 1 [(buf.validate.field).uint64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated uint64 in = 6 [(predefined).cel = { + id: "uint64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyUInt64 { + // // value must not be in list [1, 2, 3] + // uint64 value = 1 [(buf.validate.field).uint64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated uint64 not_in = 7 [(predefined).cel = { + id: "uint64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyUInt64 { + // uint64 value = 1 [ + // (buf.validate.field).uint64.example = 1, + // (buf.validate.field).uint64.example = -10 + // ]; + // } + // ``` + repeated uint64 example = 8 [(predefined).cel = { + id: "uint64.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// SInt32Rules describes the rules applied to `sint32` values. +message SInt32Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must equal 42 + // sint32 value = 1 [(buf.validate.field).sint32.const = 42]; + // } + // ``` + optional sint32 const = 1 [(predefined).cel = { + id: "sint32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field + // < value). If the field value is equal to or greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must be less than 10 + // sint32 value = 1 [(buf.validate.field).sint32.lt = 10]; + // } + // ``` + sint32 lt = 2 [(predefined).cel = { + id: "sint32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must be less than or equal to 10 + // sint32 value = 1 [(buf.validate.field).sint32.lte = 10]; + // } + // ``` + sint32 lte = 3 [(predefined).cel = { + id: "sint32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must be greater than 5 [sint32.gt] + // sint32 value = 1 [(buf.validate.field).sint32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [sint32.gt_lt] + // sint32 other_value = 2 [(buf.validate.field).sint32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [sint32.gt_lt_exclusive] + // sint32 another_value = 3 [(buf.validate.field).sint32 = { gt: 10, lt: 5 }]; + // } + // ``` + sint32 gt = 4 [ + (predefined).cel = { + id: "sint32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "sint32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sint32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must be greater than or equal to 5 [sint32.gte] + // sint32 value = 1 [(buf.validate.field).sint32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [sint32.gte_lt] + // sint32 other_value = 2 [(buf.validate.field).sint32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [sint32.gte_lt_exclusive] + // sint32 another_value = 3 [(buf.validate.field).sint32 = { gte: 10, lt: 5 }]; + // } + // ``` + sint32 gte = 5 [ + (predefined).cel = { + id: "sint32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "sint32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sint32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MySInt32 { + // // value must be in list [1, 2, 3] + // sint32 value = 1 [(buf.validate.field).sint32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated sint32 in = 6 [(predefined).cel = { + id: "sint32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MySInt32 { + // // value must not be in list [1, 2, 3] + // sint32 value = 1 [(buf.validate.field).sint32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated sint32 not_in = 7 [(predefined).cel = { + id: "sint32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MySInt32 { + // sint32 value = 1 [ + // (buf.validate.field).sint32.example = 1, + // (buf.validate.field).sint32.example = -10 + // ]; + // } + // ``` + repeated sint32 example = 8 [(predefined).cel = { + id: "sint32.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// SInt64Rules describes the rules applied to `sint64` values. +message SInt64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must equal 42 + // sint64 value = 1 [(buf.validate.field).sint64.const = 42]; + // } + // ``` + optional sint64 const = 1 [(predefined).cel = { + id: "sint64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field + // < value). If the field value is equal to or greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must be less than 10 + // sint64 value = 1 [(buf.validate.field).sint64.lt = 10]; + // } + // ``` + sint64 lt = 2 [(predefined).cel = { + id: "sint64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must be less than or equal to 10 + // sint64 value = 1 [(buf.validate.field).sint64.lte = 10]; + // } + // ``` + sint64 lte = 3 [(predefined).cel = { + id: "sint64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must be greater than 5 [sint64.gt] + // sint64 value = 1 [(buf.validate.field).sint64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [sint64.gt_lt] + // sint64 other_value = 2 [(buf.validate.field).sint64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [sint64.gt_lt_exclusive] + // sint64 another_value = 3 [(buf.validate.field).sint64 = { gt: 10, lt: 5 }]; + // } + // ``` + sint64 gt = 4 [ + (predefined).cel = { + id: "sint64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "sint64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sint64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must be greater than or equal to 5 [sint64.gte] + // sint64 value = 1 [(buf.validate.field).sint64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [sint64.gte_lt] + // sint64 other_value = 2 [(buf.validate.field).sint64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [sint64.gte_lt_exclusive] + // sint64 another_value = 3 [(buf.validate.field).sint64 = { gte: 10, lt: 5 }]; + // } + // ``` + sint64 gte = 5 [ + (predefined).cel = { + id: "sint64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "sint64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sint64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message + // is generated. + // + // ```proto + // message MySInt64 { + // // value must be in list [1, 2, 3] + // sint64 value = 1 [(buf.validate.field).sint64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated sint64 in = 6 [(predefined).cel = { + id: "sint64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MySInt64 { + // // value must not be in list [1, 2, 3] + // sint64 value = 1 [(buf.validate.field).sint64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated sint64 not_in = 7 [(predefined).cel = { + id: "sint64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MySInt64 { + // sint64 value = 1 [ + // (buf.validate.field).sint64.example = 1, + // (buf.validate.field).sint64.example = -10 + // ]; + // } + // ``` + repeated sint64 example = 8 [(predefined).cel = { + id: "sint64.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// Fixed32Rules describes the rules applied to `fixed32` values. +message Fixed32Rules { + // `const` requires the field value to exactly match the specified value. + // If the field value doesn't match, an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must equal 42 + // fixed32 value = 1 [(buf.validate.field).fixed32.const = 42]; + // } + // ``` + optional fixed32 const = 1 [(predefined).cel = { + id: "fixed32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must be less than 10 + // fixed32 value = 1 [(buf.validate.field).fixed32.lt = 10]; + // } + // ``` + fixed32 lt = 2 [(predefined).cel = { + id: "fixed32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must be less than or equal to 10 + // fixed32 value = 1 [(buf.validate.field).fixed32.lte = 10]; + // } + // ``` + fixed32 lte = 3 [(predefined).cel = { + id: "fixed32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must be greater than 5 [fixed32.gt] + // fixed32 value = 1 [(buf.validate.field).fixed32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [fixed32.gt_lt] + // fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [fixed32.gt_lt_exclusive] + // fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gt: 10, lt: 5 }]; + // } + // ``` + fixed32 gt = 4 [ + (predefined).cel = { + id: "fixed32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "fixed32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must be greater than or equal to 5 [fixed32.gte] + // fixed32 value = 1 [(buf.validate.field).fixed32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [fixed32.gte_lt] + // fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [fixed32.gte_lt_exclusive] + // fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gte: 10, lt: 5 }]; + // } + // ``` + fixed32 gte = 5 [ + (predefined).cel = { + id: "fixed32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "fixed32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "fixed32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message + // is generated. + // + // ```proto + // message MyFixed32 { + // // value must be in list [1, 2, 3] + // fixed32 value = 1 [(buf.validate.field).fixed32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated fixed32 in = 6 [(predefined).cel = { + id: "fixed32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyFixed32 { + // // value must not be in list [1, 2, 3] + // fixed32 value = 1 [(buf.validate.field).fixed32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated fixed32 not_in = 7 [(predefined).cel = { + id: "fixed32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyFixed32 { + // fixed32 value = 1 [ + // (buf.validate.field).fixed32.example = 1, + // (buf.validate.field).fixed32.example = 2 + // ]; + // } + // ``` + repeated fixed32 example = 8 [(predefined).cel = { + id: "fixed32.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// Fixed64Rules describes the rules applied to `fixed64` values. +message Fixed64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must equal 42 + // fixed64 value = 1 [(buf.validate.field).fixed64.const = 42]; + // } + // ``` + optional fixed64 const = 1 [(predefined).cel = { + id: "fixed64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must be less than 10 + // fixed64 value = 1 [(buf.validate.field).fixed64.lt = 10]; + // } + // ``` + fixed64 lt = 2 [(predefined).cel = { + id: "fixed64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must be less than or equal to 10 + // fixed64 value = 1 [(buf.validate.field).fixed64.lte = 10]; + // } + // ``` + fixed64 lte = 3 [(predefined).cel = { + id: "fixed64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must be greater than 5 [fixed64.gt] + // fixed64 value = 1 [(buf.validate.field).fixed64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [fixed64.gt_lt] + // fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [fixed64.gt_lt_exclusive] + // fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gt: 10, lt: 5 }]; + // } + // ``` + fixed64 gt = 4 [ + (predefined).cel = { + id: "fixed64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "fixed64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must be greater than or equal to 5 [fixed64.gte] + // fixed64 value = 1 [(buf.validate.field).fixed64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [fixed64.gte_lt] + // fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [fixed64.gte_lt_exclusive] + // fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gte: 10, lt: 5 }]; + // } + // ``` + fixed64 gte = 5 [ + (predefined).cel = { + id: "fixed64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "fixed64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "fixed64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyFixed64 { + // // value must be in list [1, 2, 3] + // fixed64 value = 1 [(buf.validate.field).fixed64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated fixed64 in = 6 [(predefined).cel = { + id: "fixed64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyFixed64 { + // // value must not be in list [1, 2, 3] + // fixed64 value = 1 [(buf.validate.field).fixed64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated fixed64 not_in = 7 [(predefined).cel = { + id: "fixed64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyFixed64 { + // fixed64 value = 1 [ + // (buf.validate.field).fixed64.example = 1, + // (buf.validate.field).fixed64.example = 2 + // ]; + // } + // ``` + repeated fixed64 example = 8 [(predefined).cel = { + id: "fixed64.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// SFixed32Rules describes the rules applied to `fixed32` values. +message SFixed32Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must equal 42 + // sfixed32 value = 1 [(buf.validate.field).sfixed32.const = 42]; + // } + // ``` + optional sfixed32 const = 1 [(predefined).cel = { + id: "sfixed32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must be less than 10 + // sfixed32 value = 1 [(buf.validate.field).sfixed32.lt = 10]; + // } + // ``` + sfixed32 lt = 2 [(predefined).cel = { + id: "sfixed32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must be less than or equal to 10 + // sfixed32 value = 1 [(buf.validate.field).sfixed32.lte = 10]; + // } + // ``` + sfixed32 lte = 3 [(predefined).cel = { + id: "sfixed32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must be greater than 5 [sfixed32.gt] + // sfixed32 value = 1 [(buf.validate.field).sfixed32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [sfixed32.gt_lt] + // sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [sfixed32.gt_lt_exclusive] + // sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gt: 10, lt: 5 }]; + // } + // ``` + sfixed32 gt = 4 [ + (predefined).cel = { + id: "sfixed32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must be greater than or equal to 5 [sfixed32.gte] + // sfixed32 value = 1 [(buf.validate.field).sfixed32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [sfixed32.gte_lt] + // sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [sfixed32.gte_lt_exclusive] + // sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gte: 10, lt: 5 }]; + // } + // ``` + sfixed32 gte = 5 [ + (predefined).cel = { + id: "sfixed32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MySFixed32 { + // // value must be in list [1, 2, 3] + // sfixed32 value = 1 [(buf.validate.field).sfixed32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated sfixed32 in = 6 [(predefined).cel = { + id: "sfixed32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MySFixed32 { + // // value must not be in list [1, 2, 3] + // sfixed32 value = 1 [(buf.validate.field).sfixed32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated sfixed32 not_in = 7 [(predefined).cel = { + id: "sfixed32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MySFixed32 { + // sfixed32 value = 1 [ + // (buf.validate.field).sfixed32.example = 1, + // (buf.validate.field).sfixed32.example = 2 + // ]; + // } + // ``` + repeated sfixed32 example = 8 [(predefined).cel = { + id: "sfixed32.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// SFixed64Rules describes the rules applied to `fixed64` values. +message SFixed64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must equal 42 + // sfixed64 value = 1 [(buf.validate.field).sfixed64.const = 42]; + // } + // ``` + optional sfixed64 const = 1 [(predefined).cel = { + id: "sfixed64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must be less than 10 + // sfixed64 value = 1 [(buf.validate.field).sfixed64.lt = 10]; + // } + // ``` + sfixed64 lt = 2 [(predefined).cel = { + id: "sfixed64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must be less than or equal to 10 + // sfixed64 value = 1 [(buf.validate.field).sfixed64.lte = 10]; + // } + // ``` + sfixed64 lte = 3 [(predefined).cel = { + id: "sfixed64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must be greater than 5 [sfixed64.gt] + // sfixed64 value = 1 [(buf.validate.field).sfixed64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [sfixed64.gt_lt] + // sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [sfixed64.gt_lt_exclusive] + // sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gt: 10, lt: 5 }]; + // } + // ``` + sfixed64 gt = 4 [ + (predefined).cel = { + id: "sfixed64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must be greater than or equal to 5 [sfixed64.gte] + // sfixed64 value = 1 [(buf.validate.field).sfixed64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [sfixed64.gte_lt] + // sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [sfixed64.gte_lt_exclusive] + // sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gte: 10, lt: 5 }]; + // } + // ``` + sfixed64 gte = 5 [ + (predefined).cel = { + id: "sfixed64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MySFixed64 { + // // value must be in list [1, 2, 3] + // sfixed64 value = 1 [(buf.validate.field).sfixed64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated sfixed64 in = 6 [(predefined).cel = { + id: "sfixed64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MySFixed64 { + // // value must not be in list [1, 2, 3] + // sfixed64 value = 1 [(buf.validate.field).sfixed64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated sfixed64 not_in = 7 [(predefined).cel = { + id: "sfixed64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MySFixed64 { + // sfixed64 value = 1 [ + // (buf.validate.field).sfixed64.example = 1, + // (buf.validate.field).sfixed64.example = 2 + // ]; + // } + // ``` + repeated sfixed64 example = 8 [(predefined).cel = { + id: "sfixed64.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// BoolRules describes the rules applied to `bool` values. These rules +// may also be applied to the `google.protobuf.BoolValue` Well-Known-Type. +message BoolRules { + // `const` requires the field value to exactly match the specified boolean value. + // If the field value doesn't match, an error message is generated. + // + // ```proto + // message MyBool { + // // value must equal true + // bool value = 1 [(buf.validate.field).bool.const = true]; + // } + // ``` + optional bool const = 1 [(predefined).cel = { + id: "bool.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyBool { + // bool value = 1 [ + // (buf.validate.field).bool.example = 1, + // (buf.validate.field).bool.example = 2 + // ]; + // } + // ``` + repeated bool example = 2 [(predefined).cel = { + id: "bool.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// StringRules describes the rules applied to `string` values These +// rules may also be applied to the `google.protobuf.StringValue` Well-Known-Type. +message StringRules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyString { + // // value must equal `hello` + // string value = 1 [(buf.validate.field).string.const = "hello"]; + // } + // ``` + optional string const = 1 [(predefined).cel = { + id: "string.const" + expression: "this != getField(rules, 'const') ? 'value must equal `%s`'.format([getField(rules, 'const')]) : ''" + }]; + + // `len` dictates that the field value must have the specified + // number of characters (Unicode code points), which may differ from the number + // of bytes in the string. If the field value does not meet the specified + // length, an error message will be generated. + // + // ```proto + // message MyString { + // // value length must be 5 characters + // string value = 1 [(buf.validate.field).string.len = 5]; + // } + // ``` + optional uint64 len = 19 [(predefined).cel = { + id: "string.len" + expression: "uint(this.size()) != rules.len ? 'value length must be %s characters'.format([rules.len]) : ''" + }]; + + // `min_len` specifies that the field value must have at least the specified + // number of characters (Unicode code points), which may differ from the number + // of bytes in the string. If the field value contains fewer characters, an error + // message will be generated. + // + // ```proto + // message MyString { + // // value length must be at least 3 characters + // string value = 1 [(buf.validate.field).string.min_len = 3]; + // } + // ``` + optional uint64 min_len = 2 [(predefined).cel = { + id: "string.min_len" + expression: "uint(this.size()) < rules.min_len ? 'value length must be at least %s characters'.format([rules.min_len]) : ''" + }]; + + // `max_len` specifies that the field value must have no more than the specified + // number of characters (Unicode code points), which may differ from the + // number of bytes in the string. If the field value contains more characters, + // an error message will be generated. + // + // ```proto + // message MyString { + // // value length must be at most 10 characters + // string value = 1 [(buf.validate.field).string.max_len = 10]; + // } + // ``` + optional uint64 max_len = 3 [(predefined).cel = { + id: "string.max_len" + expression: "uint(this.size()) > rules.max_len ? 'value length must be at most %s characters'.format([rules.max_len]) : ''" + }]; + + // `len_bytes` dictates that the field value must have the specified number of + // bytes. If the field value does not match the specified length in bytes, + // an error message will be generated. + // + // ```proto + // message MyString { + // // value length must be 6 bytes + // string value = 1 [(buf.validate.field).string.len_bytes = 6]; + // } + // ``` + optional uint64 len_bytes = 20 [(predefined).cel = { + id: "string.len_bytes" + expression: "uint(bytes(this).size()) != rules.len_bytes ? 'value length must be %s bytes'.format([rules.len_bytes]) : ''" + }]; + + // `min_bytes` specifies that the field value must have at least the specified + // number of bytes. If the field value contains fewer bytes, an error message + // will be generated. + // + // ```proto + // message MyString { + // // value length must be at least 4 bytes + // string value = 1 [(buf.validate.field).string.min_bytes = 4]; + // } + // + // ``` + optional uint64 min_bytes = 4 [(predefined).cel = { + id: "string.min_bytes" + expression: "uint(bytes(this).size()) < rules.min_bytes ? 'value length must be at least %s bytes'.format([rules.min_bytes]) : ''" + }]; + + // `max_bytes` specifies that the field value must have no more than the + //specified number of bytes. If the field value contains more bytes, an + // error message will be generated. + // + // ```proto + // message MyString { + // // value length must be at most 8 bytes + // string value = 1 [(buf.validate.field).string.max_bytes = 8]; + // } + // ``` + optional uint64 max_bytes = 5 [(predefined).cel = { + id: "string.max_bytes" + expression: "uint(bytes(this).size()) > rules.max_bytes ? 'value length must be at most %s bytes'.format([rules.max_bytes]) : ''" + }]; + + // `pattern` specifies that the field value must match the specified + // regular expression (RE2 syntax), with the expression provided without any + // delimiters. If the field value doesn't match the regular expression, an + // error message will be generated. + // + // ```proto + // message MyString { + // // value does not match regex pattern `^[a-zA-Z]//$` + // string value = 1 [(buf.validate.field).string.pattern = "^[a-zA-Z]//$"]; + // } + // ``` + optional string pattern = 6 [(predefined).cel = { + id: "string.pattern" + expression: "!this.matches(rules.pattern) ? 'value does not match regex pattern `%s`'.format([rules.pattern]) : ''" + }]; + + // `prefix` specifies that the field value must have the + //specified substring at the beginning of the string. If the field value + // doesn't start with the specified prefix, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value does not have prefix `pre` + // string value = 1 [(buf.validate.field).string.prefix = "pre"]; + // } + // ``` + optional string prefix = 7 [(predefined).cel = { + id: "string.prefix" + expression: "!this.startsWith(rules.prefix) ? 'value does not have prefix `%s`'.format([rules.prefix]) : ''" + }]; + + // `suffix` specifies that the field value must have the + //specified substring at the end of the string. If the field value doesn't + // end with the specified suffix, an error message will be generated. + // + // ```proto + // message MyString { + // // value does not have suffix `post` + // string value = 1 [(buf.validate.field).string.suffix = "post"]; + // } + // ``` + optional string suffix = 8 [(predefined).cel = { + id: "string.suffix" + expression: "!this.endsWith(rules.suffix) ? 'value does not have suffix `%s`'.format([rules.suffix]) : ''" + }]; + + // `contains` specifies that the field value must have the + //specified substring anywhere in the string. If the field value doesn't + // contain the specified substring, an error message will be generated. + // + // ```proto + // message MyString { + // // value does not contain substring `inside`. + // string value = 1 [(buf.validate.field).string.contains = "inside"]; + // } + // ``` + optional string contains = 9 [(predefined).cel = { + id: "string.contains" + expression: "!this.contains(rules.contains) ? 'value does not contain substring `%s`'.format([rules.contains]) : ''" + }]; + + // `not_contains` specifies that the field value must not have the + //specified substring anywhere in the string. If the field value contains + // the specified substring, an error message will be generated. + // + // ```proto + // message MyString { + // // value contains substring `inside`. + // string value = 1 [(buf.validate.field).string.not_contains = "inside"]; + // } + // ``` + optional string not_contains = 23 [(predefined).cel = { + id: "string.not_contains" + expression: "this.contains(rules.not_contains) ? 'value contains substring `%s`'.format([rules.not_contains]) : ''" + }]; + + // `in` specifies that the field value must be equal to one of the specified + // values. If the field value isn't one of the specified values, an error + // message will be generated. + // + // ```proto + // message MyString { + // // value must be in list ["apple", "banana"] + // string value = 1 [(buf.validate.field).string.in = "apple", (buf.validate.field).string.in = "banana"]; + // } + // ``` + repeated string in = 10 [(predefined).cel = { + id: "string.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` specifies that the field value cannot be equal to any + // of the specified values. If the field value is one of the specified values, + // an error message will be generated. + // ```proto + // message MyString { + // // value must not be in list ["orange", "grape"] + // string value = 1 [(buf.validate.field).string.not_in = "orange", (buf.validate.field).string.not_in = "grape"]; + // } + // ``` + repeated string not_in = 11 [(predefined).cel = { + id: "string.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `WellKnown` rules provide advanced rules against common string + // patterns. + oneof well_known { + // `email` specifies that the field value must be a valid email address, for + // example "foo@example.com". + // + // Conforms to the definition for a valid email address from the [HTML standard](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address). + // Note that this standard willfully deviates from [RFC 5322](https://datatracker.ietf.org/doc/html/rfc5322), + // which allows many unexpected forms of email addresses and will easily match + // a typographical error. + // + // If the field value isn't a valid email address, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid email address + // string value = 1 [(buf.validate.field).string.email = true]; + // } + // ``` + bool email = 12 [ + (predefined).cel = { + id: "string.email" + message: "value must be a valid email address" + expression: "!rules.email || this == '' || this.isEmail()" + }, + (predefined).cel = { + id: "string.email_empty" + message: "value is empty, which is not a valid email address" + expression: "!rules.email || this != ''" + } + ]; + + // `hostname` specifies that the field value must be a valid hostname, for + // example "foo.example.com". + // + // A valid hostname follows the rules below: + // - The name consists of one or more labels, separated by a dot ("."). + // - Each label can be 1 to 63 alphanumeric characters. + // - A label can contain hyphens ("-"), but must not start or end with a hyphen. + // - The right-most label must not be digits only. + // - The name can have a trailing dot—for example, "foo.example.com.". + // - The name can be 253 characters at most, excluding the optional trailing dot. + // + // If the field value isn't a valid hostname, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid hostname + // string value = 1 [(buf.validate.field).string.hostname = true]; + // } + // ``` + bool hostname = 13 [ + (predefined).cel = { + id: "string.hostname" + message: "value must be a valid hostname" + expression: "!rules.hostname || this == '' || this.isHostname()" + }, + (predefined).cel = { + id: "string.hostname_empty" + message: "value is empty, which is not a valid hostname" + expression: "!rules.hostname || this != ''" + } + ]; + + // `ip` specifies that the field value must be a valid IP (v4 or v6) address. + // + // IPv4 addresses are expected in the dotted decimal format—for example, "192.168.5.21". + // IPv6 addresses are expected in their text representation—for example, "::1", + // or "2001:0DB8:ABCD:0012::0". + // + // Both formats are well-defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). + // Zone identifiers for IPv6 addresses (for example, "fe80::a%en1") are supported. + // + // If the field value isn't a valid IP address, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value must be a valid IP address + // string value = 1 [(buf.validate.field).string.ip = true]; + // } + // ``` + bool ip = 14 [ + (predefined).cel = { + id: "string.ip" + message: "value must be a valid IP address" + expression: "!rules.ip || this == '' || this.isIp()" + }, + (predefined).cel = { + id: "string.ip_empty" + message: "value is empty, which is not a valid IP address" + expression: "!rules.ip || this != ''" + } + ]; + + // `ipv4` specifies that the field value must be a valid IPv4 address—for + // example "192.168.5.21". If the field value isn't a valid IPv4 address, an + // error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv4 address + // string value = 1 [(buf.validate.field).string.ipv4 = true]; + // } + // ``` + bool ipv4 = 15 [ + (predefined).cel = { + id: "string.ipv4" + message: "value must be a valid IPv4 address" + expression: "!rules.ipv4 || this == '' || this.isIp(4)" + }, + (predefined).cel = { + id: "string.ipv4_empty" + message: "value is empty, which is not a valid IPv4 address" + expression: "!rules.ipv4 || this != ''" + } + ]; + + // `ipv6` specifies that the field value must be a valid IPv6 address—for + // example "::1", or "d7a:115c:a1e0:ab12:4843:cd96:626b:430b". If the field + // value is not a valid IPv6 address, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv6 address + // string value = 1 [(buf.validate.field).string.ipv6 = true]; + // } + // ``` + bool ipv6 = 16 [ + (predefined).cel = { + id: "string.ipv6" + message: "value must be a valid IPv6 address" + expression: "!rules.ipv6 || this == '' || this.isIp(6)" + }, + (predefined).cel = { + id: "string.ipv6_empty" + message: "value is empty, which is not a valid IPv6 address" + expression: "!rules.ipv6 || this != ''" + } + ]; + + // `uri` specifies that the field value must be a valid URI, for example + // "https://example.com/foo/bar?baz=quux#frag". + // + // URI is defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). + // Zone Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)). + // + // If the field value isn't a valid URI, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid URI + // string value = 1 [(buf.validate.field).string.uri = true]; + // } + // ``` + bool uri = 17 [ + (predefined).cel = { + id: "string.uri" + message: "value must be a valid URI" + expression: "!rules.uri || this == '' || this.isUri()" + }, + (predefined).cel = { + id: "string.uri_empty" + message: "value is empty, which is not a valid URI" + expression: "!rules.uri || this != ''" + } + ]; + + // `uri_ref` specifies that the field value must be a valid URI Reference—either + // a URI such as "https://example.com/foo/bar?baz=quux#frag", or a Relative + // Reference such as "./foo/bar?query". + // + // URI, URI Reference, and Relative Reference are defined in the internet + // standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). Zone + // Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)). + // + // If the field value isn't a valid URI Reference, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value must be a valid URI Reference + // string value = 1 [(buf.validate.field).string.uri_ref = true]; + // } + // ``` + bool uri_ref = 18 [(predefined).cel = { + id: "string.uri_ref" + message: "value must be a valid URI Reference" + expression: "!rules.uri_ref || this.isUriRef()" + }]; + + // `address` specifies that the field value must be either a valid hostname + // (for example, "example.com"), or a valid IP (v4 or v6) address (for example, + // "192.168.0.1", or "::1"). If the field value isn't a valid hostname or IP, + // an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid hostname, or ip address + // string value = 1 [(buf.validate.field).string.address = true]; + // } + // ``` + bool address = 21 [ + (predefined).cel = { + id: "string.address" + message: "value must be a valid hostname, or ip address" + expression: "!rules.address || this == '' || this.isHostname() || this.isIp()" + }, + (predefined).cel = { + id: "string.address_empty" + message: "value is empty, which is not a valid hostname, or ip address" + expression: "!rules.address || this != ''" + } + ]; + + // `uuid` specifies that the field value must be a valid UUID as defined by + // [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2). If the + // field value isn't a valid UUID, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid UUID + // string value = 1 [(buf.validate.field).string.uuid = true]; + // } + // ``` + bool uuid = 22 [ + (predefined).cel = { + id: "string.uuid" + message: "value must be a valid UUID" + expression: "!rules.uuid || this == '' || this.matches('^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$')" + }, + (predefined).cel = { + id: "string.uuid_empty" + message: "value is empty, which is not a valid UUID" + expression: "!rules.uuid || this != ''" + } + ]; + + // `tuuid` (trimmed UUID) specifies that the field value must be a valid UUID as + // defined by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2) with all dashes + // omitted. If the field value isn't a valid UUID without dashes, an error message + // will be generated. + // + // ```proto + // message MyString { + // // value must be a valid trimmed UUID + // string value = 1 [(buf.validate.field).string.tuuid = true]; + // } + // ``` + bool tuuid = 33 [ + (predefined).cel = { + id: "string.tuuid" + message: "value must be a valid trimmed UUID" + expression: "!rules.tuuid || this == '' || this.matches('^[0-9a-fA-F]{32}$')" + }, + (predefined).cel = { + id: "string.tuuid_empty" + message: "value is empty, which is not a valid trimmed UUID" + expression: "!rules.tuuid || this != ''" + } + ]; + + // `ip_with_prefixlen` specifies that the field value must be a valid IP + // (v4 or v6) address with prefix length—for example, "192.168.5.21/16" or + // "2001:0DB8:ABCD:0012::F1/64". If the field value isn't a valid IP with + // prefix length, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IP with prefix length + // string value = 1 [(buf.validate.field).string.ip_with_prefixlen = true]; + // } + // ``` + bool ip_with_prefixlen = 26 [ + (predefined).cel = { + id: "string.ip_with_prefixlen" + message: "value must be a valid IP prefix" + expression: "!rules.ip_with_prefixlen || this == '' || this.isIpPrefix()" + }, + (predefined).cel = { + id: "string.ip_with_prefixlen_empty" + message: "value is empty, which is not a valid IP prefix" + expression: "!rules.ip_with_prefixlen || this != ''" + } + ]; + + // `ipv4_with_prefixlen` specifies that the field value must be a valid + // IPv4 address with prefix length—for example, "192.168.5.21/16". If the + // field value isn't a valid IPv4 address with prefix length, an error + // message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv4 address with prefix length + // string value = 1 [(buf.validate.field).string.ipv4_with_prefixlen = true]; + // } + // ``` + bool ipv4_with_prefixlen = 27 [ + (predefined).cel = { + id: "string.ipv4_with_prefixlen" + message: "value must be a valid IPv4 address with prefix length" + expression: "!rules.ipv4_with_prefixlen || this == '' || this.isIpPrefix(4)" + }, + (predefined).cel = { + id: "string.ipv4_with_prefixlen_empty" + message: "value is empty, which is not a valid IPv4 address with prefix length" + expression: "!rules.ipv4_with_prefixlen || this != ''" + } + ]; + + // `ipv6_with_prefixlen` specifies that the field value must be a valid + // IPv6 address with prefix length—for example, "2001:0DB8:ABCD:0012::F1/64". + // If the field value is not a valid IPv6 address with prefix length, + // an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv6 address prefix length + // string value = 1 [(buf.validate.field).string.ipv6_with_prefixlen = true]; + // } + // ``` + bool ipv6_with_prefixlen = 28 [ + (predefined).cel = { + id: "string.ipv6_with_prefixlen" + message: "value must be a valid IPv6 address with prefix length" + expression: "!rules.ipv6_with_prefixlen || this == '' || this.isIpPrefix(6)" + }, + (predefined).cel = { + id: "string.ipv6_with_prefixlen_empty" + message: "value is empty, which is not a valid IPv6 address with prefix length" + expression: "!rules.ipv6_with_prefixlen || this != ''" + } + ]; + + // `ip_prefix` specifies that the field value must be a valid IP (v4 or v6) + // prefix—for example, "192.168.0.0/16" or "2001:0DB8:ABCD:0012::0/64". + // + // The prefix must have all zeros for the unmasked bits. For example, + // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the + // prefix, and the remaining 64 bits must be zero. + // + // If the field value isn't a valid IP prefix, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value must be a valid IP prefix + // string value = 1 [(buf.validate.field).string.ip_prefix = true]; + // } + // ``` + bool ip_prefix = 29 [ + (predefined).cel = { + id: "string.ip_prefix" + message: "value must be a valid IP prefix" + expression: "!rules.ip_prefix || this == '' || this.isIpPrefix(true)" + }, + (predefined).cel = { + id: "string.ip_prefix_empty" + message: "value is empty, which is not a valid IP prefix" + expression: "!rules.ip_prefix || this != ''" + } + ]; + + // `ipv4_prefix` specifies that the field value must be a valid IPv4 + // prefix, for example "192.168.0.0/16". + // + // The prefix must have all zeros for the unmasked bits. For example, + // "192.168.0.0/16" designates the left-most 16 bits for the prefix, + // and the remaining 16 bits must be zero. + // + // If the field value isn't a valid IPv4 prefix, an error message + // will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv4 prefix + // string value = 1 [(buf.validate.field).string.ipv4_prefix = true]; + // } + // ``` + bool ipv4_prefix = 30 [ + (predefined).cel = { + id: "string.ipv4_prefix" + message: "value must be a valid IPv4 prefix" + expression: "!rules.ipv4_prefix || this == '' || this.isIpPrefix(4, true)" + }, + (predefined).cel = { + id: "string.ipv4_prefix_empty" + message: "value is empty, which is not a valid IPv4 prefix" + expression: "!rules.ipv4_prefix || this != ''" + } + ]; + + // `ipv6_prefix` specifies that the field value must be a valid IPv6 prefix—for + // example, "2001:0DB8:ABCD:0012::0/64". + // + // The prefix must have all zeros for the unmasked bits. For example, + // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the + // prefix, and the remaining 64 bits must be zero. + // + // If the field value is not a valid IPv6 prefix, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv6 prefix + // string value = 1 [(buf.validate.field).string.ipv6_prefix = true]; + // } + // ``` + bool ipv6_prefix = 31 [ + (predefined).cel = { + id: "string.ipv6_prefix" + message: "value must be a valid IPv6 prefix" + expression: "!rules.ipv6_prefix || this == '' || this.isIpPrefix(6, true)" + }, + (predefined).cel = { + id: "string.ipv6_prefix_empty" + message: "value is empty, which is not a valid IPv6 prefix" + expression: "!rules.ipv6_prefix || this != ''" + } + ]; + + // `host_and_port` specifies that the field value must be valid host/port + // pair—for example, "example.com:8080". + // + // The host can be one of: + //- An IPv4 address in dotted decimal format—for example, "192.168.5.21". + //- An IPv6 address enclosed in square brackets—for example, "[2001:0DB8:ABCD:0012::F1]". + //- A hostname—for example, "example.com". + // + // The port is separated by a colon. It must be non-empty, with a decimal number + // in the range of 0-65535, inclusive. + bool host_and_port = 32 [ + (predefined).cel = { + id: "string.host_and_port" + message: "value must be a valid host (hostname or IP address) and port pair" + expression: "!rules.host_and_port || this == '' || this.isHostAndPort(true)" + }, + (predefined).cel = { + id: "string.host_and_port_empty" + message: "value is empty, which is not a valid host and port pair" + expression: "!rules.host_and_port || this != ''" + } + ]; + + // `ulid` specifies that the field value must be a valid ULID (Universally Unique + // Lexicographically Sortable Identifier) as defined by the [ULID specification](https://github.com/ulid/spec). + // If the field value isn't a valid ULID, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid ULID + // string value = 1 [(buf.validate.field).string.ulid = true]; + // } + // ``` + bool ulid = 35 [ + (predefined).cel = { + id: "string.ulid" + message: "value must be a valid ULID" + expression: "!rules.ulid || this == '' || this.matches('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$')" + }, + (predefined).cel = { + id: "string.ulid_empty" + message: "value is empty, which is not a valid ULID" + expression: "!rules.ulid || this != ''" + } + ]; + + // `well_known_regex` specifies a common well-known pattern + // defined as a regex. If the field value doesn't match the well-known + // regex, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid HTTP header value + // string value = 1 [(buf.validate.field).string.well_known_regex = KNOWN_REGEX_HTTP_HEADER_VALUE]; + // } + // ``` + // + // #### KnownRegex + // + // `well_known_regex` contains some well-known patterns. + // + // | Name | Number | Description | + // |-------------------------------|--------|-------------------------------------------| + // | KNOWN_REGEX_UNSPECIFIED | 0 | | + // | KNOWN_REGEX_HTTP_HEADER_NAME | 1 | HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2) | + // | KNOWN_REGEX_HTTP_HEADER_VALUE | 2 | HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4) | + KnownRegex well_known_regex = 24 [ + (predefined).cel = { + id: "string.well_known_regex.header_name" + message: "value must be a valid HTTP header name" + expression: + "rules.well_known_regex != 1 || this == '' || this.matches(!has(rules.strict) || rules.strict ?" + "'^:?[0-9a-zA-Z!#$%&\\'*+-.^_|~\\x60]+$' :" + "'^[^\\u0000\\u000A\\u000D]+$')" + }, + (predefined).cel = { + id: "string.well_known_regex.header_name_empty" + message: "value is empty, which is not a valid HTTP header name" + expression: "rules.well_known_regex != 1 || this != ''" + }, + (predefined).cel = { + id: "string.well_known_regex.header_value" + message: "value must be a valid HTTP header value" + expression: + "rules.well_known_regex != 2 || this.matches(!has(rules.strict) || rules.strict ?" + "'^[^\\u0000-\\u0008\\u000A-\\u001F\\u007F]*$' :" + "'^[^\\u0000\\u000A\\u000D]*$')" + } + ]; + } + + // This applies to regexes `HTTP_HEADER_NAME` and `HTTP_HEADER_VALUE` to + // enable strict header validation. By default, this is true, and HTTP header + // validations are [RFC-compliant](https://datatracker.ietf.org/doc/html/rfc7230#section-3). Setting to false will enable looser + // validations that only disallow `\r\n\0` characters, which can be used to + // bypass header matching rules. + // + // ```proto + // message MyString { + // // The field `value` must have be a valid HTTP headers, but not enforced with strict rules. + // string value = 1 [(buf.validate.field).string.strict = false]; + // } + // ``` + optional bool strict = 25; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyString { + // string value = 1 [ + // (buf.validate.field).string.example = "hello", + // (buf.validate.field).string.example = "world" + // ]; + // } + // ``` + repeated string example = 34 [(predefined).cel = { + id: "string.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// KnownRegex contains some well-known patterns. +enum KnownRegex { + KNOWN_REGEX_UNSPECIFIED = 0; + + // HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2). + KNOWN_REGEX_HTTP_HEADER_NAME = 1; + + // HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4). + KNOWN_REGEX_HTTP_HEADER_VALUE = 2; +} + +// BytesRules describe the rules applied to `bytes` values. These rules +// may also be applied to the `google.protobuf.BytesValue` Well-Known-Type. +message BytesRules { + // `const` requires the field value to exactly match the specified bytes + // value. If the field value doesn't match, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must be "\x01\x02\x03\x04" + // bytes value = 1 [(buf.validate.field).bytes.const = "\x01\x02\x03\x04"]; + // } + // ``` + optional bytes const = 1 [(predefined).cel = { + id: "bytes.const" + expression: "this != getField(rules, 'const') ? 'value must be %x'.format([getField(rules, 'const')]) : ''" + }]; + + // `len` requires the field value to have the specified length in bytes. + // If the field value doesn't match, an error message is generated. + // + // ```proto + // message MyBytes { + // // value length must be 4 bytes. + // optional bytes value = 1 [(buf.validate.field).bytes.len = 4]; + // } + // ``` + optional uint64 len = 13 [(predefined).cel = { + id: "bytes.len" + expression: "uint(this.size()) != rules.len ? 'value length must be %s bytes'.format([rules.len]) : ''" + }]; + + // `min_len` requires the field value to have at least the specified minimum + // length in bytes. + // If the field value doesn't meet the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value length must be at least 2 bytes. + // optional bytes value = 1 [(buf.validate.field).bytes.min_len = 2]; + // } + // ``` + optional uint64 min_len = 2 [(predefined).cel = { + id: "bytes.min_len" + expression: "uint(this.size()) < rules.min_len ? 'value length must be at least %s bytes'.format([rules.min_len]) : ''" + }]; + + // `max_len` requires the field value to have at most the specified maximum + // length in bytes. + // If the field value exceeds the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must be at most 6 bytes. + // optional bytes value = 1 [(buf.validate.field).bytes.max_len = 6]; + // } + // ``` + optional uint64 max_len = 3 [(predefined).cel = { + id: "bytes.max_len" + expression: "uint(this.size()) > rules.max_len ? 'value must be at most %s bytes'.format([rules.max_len]) : ''" + }]; + + // `pattern` requires the field value to match the specified regular + // expression ([RE2 syntax](https://github.com/google/re2/wiki/Syntax)). + // The value of the field must be valid UTF-8 or validation will fail with a + // runtime error. + // If the field value doesn't match the pattern, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must match regex pattern "^[a-zA-Z0-9]+$". + // optional bytes value = 1 [(buf.validate.field).bytes.pattern = "^[a-zA-Z0-9]+$"]; + // } + // ``` + optional string pattern = 4 [(predefined).cel = { + id: "bytes.pattern" + expression: "!string(this).matches(rules.pattern) ? 'value must match regex pattern `%s`'.format([rules.pattern]) : ''" + }]; + + // `prefix` requires the field value to have the specified bytes at the + // beginning of the string. + // If the field value doesn't meet the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value does not have prefix \x01\x02 + // optional bytes value = 1 [(buf.validate.field).bytes.prefix = "\x01\x02"]; + // } + // ``` + optional bytes prefix = 5 [(predefined).cel = { + id: "bytes.prefix" + expression: "!this.startsWith(rules.prefix) ? 'value does not have prefix %x'.format([rules.prefix]) : ''" + }]; + + // `suffix` requires the field value to have the specified bytes at the end + // of the string. + // If the field value doesn't meet the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value does not have suffix \x03\x04 + // optional bytes value = 1 [(buf.validate.field).bytes.suffix = "\x03\x04"]; + // } + // ``` + optional bytes suffix = 6 [(predefined).cel = { + id: "bytes.suffix" + expression: "!this.endsWith(rules.suffix) ? 'value does not have suffix %x'.format([rules.suffix]) : ''" + }]; + + // `contains` requires the field value to have the specified bytes anywhere in + // the string. + // If the field value doesn't meet the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value does not contain \x02\x03 + // optional bytes value = 1 [(buf.validate.field).bytes.contains = "\x02\x03"]; + // } + // ``` + optional bytes contains = 7 [(predefined).cel = { + id: "bytes.contains" + expression: "!this.contains(rules.contains) ? 'value does not contain %x'.format([rules.contains]) : ''" + }]; + + // `in` requires the field value to be equal to one of the specified + // values. If the field value doesn't match any of the specified values, an + // error message is generated. + // + // ```proto + // message MyBytes { + // // value must in ["\x01\x02", "\x02\x03", "\x03\x04"] + // optional bytes value = 1 [(buf.validate.field).bytes.in = {"\x01\x02", "\x02\x03", "\x03\x04"}]; + // } + // ``` + repeated bytes in = 8 [(predefined).cel = { + id: "bytes.in" + expression: "getField(rules, 'in').size() > 0 && !(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to be not equal to any of the specified + // values. + // If the field value matches any of the specified values, an error message is + // generated. + // + // ```proto + // message MyBytes { + // // value must not in ["\x01\x02", "\x02\x03", "\x03\x04"] + // optional bytes value = 1 [(buf.validate.field).bytes.not_in = {"\x01\x02", "\x02\x03", "\x03\x04"}]; + // } + // ``` + repeated bytes not_in = 9 [(predefined).cel = { + id: "bytes.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // WellKnown rules provide advanced rules against common byte + // patterns + oneof well_known { + // `ip` ensures that the field `value` is a valid IP address (v4 or v6) in byte format. + // If the field value doesn't meet this rule, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must be a valid IP address + // optional bytes value = 1 [(buf.validate.field).bytes.ip = true]; + // } + // ``` + bool ip = 10 [ + (predefined).cel = { + id: "bytes.ip" + message: "value must be a valid IP address" + expression: "!rules.ip || this.size() == 0 || this.size() == 4 || this.size() == 16" + }, + (predefined).cel = { + id: "bytes.ip_empty" + message: "value is empty, which is not a valid IP address" + expression: "!rules.ip || this.size() != 0" + } + ]; + + // `ipv4` ensures that the field `value` is a valid IPv4 address in byte format. + // If the field value doesn't meet this rule, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must be a valid IPv4 address + // optional bytes value = 1 [(buf.validate.field).bytes.ipv4 = true]; + // } + // ``` + bool ipv4 = 11 [ + (predefined).cel = { + id: "bytes.ipv4" + message: "value must be a valid IPv4 address" + expression: "!rules.ipv4 || this.size() == 0 || this.size() == 4" + }, + (predefined).cel = { + id: "bytes.ipv4_empty" + message: "value is empty, which is not a valid IPv4 address" + expression: "!rules.ipv4 || this.size() != 0" + } + ]; + + // `ipv6` ensures that the field `value` is a valid IPv6 address in byte format. + // If the field value doesn't meet this rule, an error message is generated. + // ```proto + // message MyBytes { + // // value must be a valid IPv6 address + // optional bytes value = 1 [(buf.validate.field).bytes.ipv6 = true]; + // } + // ``` + bool ipv6 = 12 [ + (predefined).cel = { + id: "bytes.ipv6" + message: "value must be a valid IPv6 address" + expression: "!rules.ipv6 || this.size() == 0 || this.size() == 16" + }, + (predefined).cel = { + id: "bytes.ipv6_empty" + message: "value is empty, which is not a valid IPv6 address" + expression: "!rules.ipv6 || this.size() != 0" + } + ]; + + // `uuid` ensures that the field `value` encodes the 128-bit UUID data as + // defined by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2). + // The field must contain exactly 16 bytes + // representing the UUID. If the field value isn't a valid UUID, an error + // message will be generated. + // + // ```proto + // message MyBytes { + // // value must be a valid UUID + // optional bytes value = 1 [(buf.validate.field).bytes.uuid = true]; + // } + // ``` + bool uuid = 15 [ + (predefined).cel = { + id: "bytes.uuid" + message: "value must be a valid UUID" + expression: "!rules.uuid || this.size() == 0 || this.size() == 16" + }, + (predefined).cel = { + id: "bytes.uuid_empty" + message: "value is empty, which is not a valid UUID" + expression: "!rules.uuid || this.size() != 0" + } + ]; + } + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyBytes { + // bytes value = 1 [ + // (buf.validate.field).bytes.example = "\x01\x02", + // (buf.validate.field).bytes.example = "\x02\x03" + // ]; + // } + // ``` + repeated bytes example = 14 [(predefined).cel = { + id: "bytes.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// EnumRules describe the rules applied to `enum` values. +message EnumRules { + // `const` requires the field value to exactly match the specified enum value. + // If the field value doesn't match, an error message is generated. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // // The field `value` must be exactly MY_ENUM_VALUE1. + // MyEnum value = 1 [(buf.validate.field).enum.const = 1]; + // } + // ``` + optional int32 const = 1 [(predefined).cel = { + id: "enum.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + + // `defined_only` requires the field value to be one of the defined values for + // this enum, failing on any undefined value. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // // The field `value` must be a defined value of MyEnum. + // MyEnum value = 1 [(buf.validate.field).enum.defined_only = true]; + // } + // ``` + optional bool defined_only = 2; + + // `in` requires the field value to be equal to one of the + //specified enum values. If the field value doesn't match any of the + //specified values, an error message is generated. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // // The field `value` must be equal to one of the specified values. + // MyEnum value = 1 [(buf.validate.field).enum = { in: [1, 2]}]; + // } + // ``` + repeated int32 in = 3 [(predefined).cel = { + id: "enum.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to be not equal to any of the + //specified enum values. If the field value matches one of the specified + // values, an error message is generated. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // // The field `value` must not be equal to any of the specified values. + // MyEnum value = 1 [(buf.validate.field).enum = { not_in: [1, 2]}]; + // } + // ``` + repeated int32 not_in = 4 [(predefined).cel = { + id: "enum.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // (buf.validate.field).enum.example = 1, + // (buf.validate.field).enum.example = 2 + // } + // ``` + repeated int32 example = 5 [(predefined).cel = { + id: "enum.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// RepeatedRules describe the rules applied to `repeated` values. +message RepeatedRules { + // `min_items` requires that this field must contain at least the specified + // minimum number of items. + // + // Note that `min_items = 1` is equivalent to setting a field as `required`. + // + // ```proto + // message MyRepeated { + // // value must contain at least 2 items + // repeated string value = 1 [(buf.validate.field).repeated.min_items = 2]; + // } + // ``` + optional uint64 min_items = 1 [(predefined).cel = { + id: "repeated.min_items" + expression: "uint(this.size()) < rules.min_items ? 'value must contain at least %d item(s)'.format([rules.min_items]) : ''" + }]; + + // `max_items` denotes that this field must not exceed a + // certain number of items as the upper limit. If the field contains more + // items than specified, an error message will be generated, requiring the + // field to maintain no more than the specified number of items. + // + // ```proto + // message MyRepeated { + // // value must contain no more than 3 item(s) + // repeated string value = 1 [(buf.validate.field).repeated.max_items = 3]; + // } + // ``` + optional uint64 max_items = 2 [(predefined).cel = { + id: "repeated.max_items" + expression: "uint(this.size()) > rules.max_items ? 'value must contain no more than %s item(s)'.format([rules.max_items]) : ''" + }]; + + // `unique` indicates that all elements in this field must + // be unique. This rule is strictly applicable to scalar and enum + // types, with message types not being supported. + // + // ```proto + // message MyRepeated { + // // repeated value must contain unique items + // repeated string value = 1 [(buf.validate.field).repeated.unique = true]; + // } + // ``` + optional bool unique = 3 [(predefined).cel = { + id: "repeated.unique" + message: "repeated value must contain unique items" + expression: "!rules.unique || this.unique()" + }]; + + // `items` details the rules to be applied to each item + // in the field. Even for repeated message fields, validation is executed + // against each item unless `ignore` is specified. + // + // ```proto + // message MyRepeated { + // // The items in the field `value` must follow the specified rules. + // repeated string value = 1 [(buf.validate.field).repeated.items = { + // string: { + // min_len: 3 + // max_len: 10 + // } + // }]; + // } + // ``` + // + // Note that the `required` rule does not apply. Repeated items + // cannot be unset. + optional FieldRules items = 4; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// MapRules describe the rules applied to `map` values. +message MapRules { + // Specifies the minimum number of key-value pairs allowed. If the field has + // fewer key-value pairs than specified, an error message is generated. + // + // ```proto + // message MyMap { + // // The field `value` must have at least 2 key-value pairs. + // map value = 1 [(buf.validate.field).map.min_pairs = 2]; + // } + // ``` + optional uint64 min_pairs = 1 [(predefined).cel = { + id: "map.min_pairs" + expression: "uint(this.size()) < rules.min_pairs ? 'map must be at least %d entries'.format([rules.min_pairs]) : ''" + }]; + + // Specifies the maximum number of key-value pairs allowed. If the field has + // more key-value pairs than specified, an error message is generated. + // + // ```proto + // message MyMap { + // // The field `value` must have at most 3 key-value pairs. + // map value = 1 [(buf.validate.field).map.max_pairs = 3]; + // } + // ``` + optional uint64 max_pairs = 2 [(predefined).cel = { + id: "map.max_pairs" + expression: "uint(this.size()) > rules.max_pairs ? 'map must be at most %d entries'.format([rules.max_pairs]) : ''" + }]; + + // Specifies the rules to be applied to each key in the field. + // + // ```proto + // message MyMap { + // // The keys in the field `value` must follow the specified rules. + // map value = 1 [(buf.validate.field).map.keys = { + // string: { + // min_len: 3 + // max_len: 10 + // } + // }]; + // } + // ``` + // + // Note that the `required` rule does not apply. Map keys cannot be unset. + optional FieldRules keys = 4; + + // Specifies the rules to be applied to the value of each key in the + // field. Message values will still have their validations evaluated unless + // `ignore` is specified. + // + // ```proto + // message MyMap { + // // The values in the field `value` must follow the specified rules. + // map value = 1 [(buf.validate.field).map.values = { + // string: { + // min_len: 5 + // max_len: 20 + // } + // }]; + // } + // ``` + // Note that the `required` rule does not apply. Map values cannot be unset. + optional FieldRules values = 5; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// AnyRules describe rules applied exclusively to the `google.protobuf.Any` well-known type. +message AnyRules { + // `in` requires the field's `type_url` to be equal to one of the + //specified values. If it doesn't match any of the specified values, an error + // message is generated. + // + // ```proto + // message MyAny { + // // The `value` field must have a `type_url` equal to one of the specified values. + // google.protobuf.Any value = 1 [(buf.validate.field).any = { + // in: ["type.googleapis.com/MyType1", "type.googleapis.com/MyType2"] + // }]; + // } + // ``` + repeated string in = 2; + + // requires the field's type_url to be not equal to any of the specified values. If it matches any of the specified values, an error message is generated. + // + // ```proto + // message MyAny { + // // The `value` field must not have a `type_url` equal to any of the specified values. + // google.protobuf.Any value = 1 [(buf.validate.field).any = { + // not_in: ["type.googleapis.com/ForbiddenType1", "type.googleapis.com/ForbiddenType2"] + // }]; + // } + // ``` + repeated string not_in = 3; +} + +// DurationRules describe the rules applied exclusively to the `google.protobuf.Duration` well-known type. +message DurationRules { + // `const` dictates that the field must match the specified value of the `google.protobuf.Duration` type exactly. + // If the field's value deviates from the specified value, an error message + // will be generated. + // + // ```proto + // message MyDuration { + // // value must equal 5s + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.const = "5s"]; + // } + // ``` + optional google.protobuf.Duration const = 2 [(predefined).cel = { + id: "duration.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` stipulates that the field must be less than the specified value of the `google.protobuf.Duration` type, + // exclusive. If the field's value is greater than or equal to the specified + // value, an error message will be generated. + // + // ```proto + // message MyDuration { + // // value must be less than 5s + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lt = "5s"]; + // } + // ``` + google.protobuf.Duration lt = 3 [(predefined).cel = { + id: "duration.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` indicates that the field must be less than or equal to the specified + // value of the `google.protobuf.Duration` type, inclusive. If the field's value is greater than the specified value, + // an error message will be generated. + // + // ```proto + // message MyDuration { + // // value must be less than or equal to 10s + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lte = "10s"]; + // } + // ``` + google.protobuf.Duration lte = 4 [(predefined).cel = { + id: "duration.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the duration field value to be greater than the specified + // value (exclusive). If the value of `gt` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyDuration { + // // duration must be greater than 5s [duration.gt] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.gt = { seconds: 5 }]; + // + // // duration must be greater than 5s and less than 10s [duration.gt_lt] + // google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gt: { seconds: 5 }, lt: { seconds: 10 } }]; + // + // // duration must be greater than 10s or less than 5s [duration.gt_lt_exclusive] + // google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gt: { seconds: 10 }, lt: { seconds: 5 } }]; + // } + // ``` + google.protobuf.Duration gt = 5 [ + (predefined).cel = { + id: "duration.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "duration.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "duration.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "duration.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "duration.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the duration field value to be greater than or equal to the + // specified value (exclusive). If the value of `gte` is larger than a + // specified `lt` or `lte`, the range is reversed, and the field value must + // be outside the specified range. If the field value doesn't meet the + // required conditions, an error message is generated. + // + // ```proto + // message MyDuration { + // // duration must be greater than or equal to 5s [duration.gte] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.gte = { seconds: 5 }]; + // + // // duration must be greater than or equal to 5s and less than 10s [duration.gte_lt] + // google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gte: { seconds: 5 }, lt: { seconds: 10 } }]; + // + // // duration must be greater than or equal to 10s or less than 5s [duration.gte_lt_exclusive] + // google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gte: { seconds: 10 }, lt: { seconds: 5 } }]; + // } + // ``` + google.protobuf.Duration gte = 6 [ + (predefined).cel = { + id: "duration.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "duration.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "duration.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "duration.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "duration.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` asserts that the field must be equal to one of the specified values of the `google.protobuf.Duration` type. + // If the field's value doesn't correspond to any of the specified values, + // an error message will be generated. + // + // ```proto + // message MyDuration { + // // value must be in list [1s, 2s, 3s] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.in = ["1s", "2s", "3s"]]; + // } + // ``` + repeated google.protobuf.Duration in = 7 [(predefined).cel = { + id: "duration.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` denotes that the field must not be equal to + // any of the specified values of the `google.protobuf.Duration` type. + // If the field's value matches any of these values, an error message will be + // generated. + // + // ```proto + // message MyDuration { + // // value must not be in list [1s, 2s, 3s] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.not_in = ["1s", "2s", "3s"]]; + // } + // ``` + repeated google.protobuf.Duration not_in = 8 [(predefined).cel = { + id: "duration.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyDuration { + // google.protobuf.Duration value = 1 [ + // (buf.validate.field).duration.example = { seconds: 1 }, + // (buf.validate.field).duration.example = { seconds: 2 }, + // ]; + // } + // ``` + repeated google.protobuf.Duration example = 9 [(predefined).cel = { + id: "duration.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// FieldMaskRules describe rules applied exclusively to the `google.protobuf.FieldMask` well-known type. +message FieldMaskRules { + // `const` dictates that the field must match the specified value of the `google.protobuf.FieldMask` type exactly. + // If the field's value deviates from the specified value, an error message + // will be generated. + // + // ```proto + // message MyFieldMask { + // // value must equal ["a"] + // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask.const = { + // paths: ["a"] + // }]; + // } + // ``` + optional google.protobuf.FieldMask const = 1 [(predefined).cel = { + id: "field_mask.const" + expression: "this.paths != getField(rules, 'const').paths ? 'value must equal paths %s'.format([getField(rules, 'const').paths]) : ''" + }]; + + // `in` requires the field value to only contain paths matching specified + // values or their subpaths. + // If any of the field value's paths doesn't match the rule, + // an error message is generated. + // See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask + // + // ```proto + // message MyFieldMask { + // // The `value` FieldMask must only contain paths listed in `in`. + // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = { + // in: ["a", "b", "c.a"] + // }]; + // } + // ``` + repeated string in = 2 [(predefined).cel = { + id: "field_mask.in" + expression: "!this.paths.all(p, p in getField(rules, 'in') || getField(rules, 'in').exists(f, p.startsWith(f+'.'))) ? 'value must only contain paths in %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not contain paths matching specified + // values or their subpaths. + // If any of the field value's paths matches the rule, + // an error message is generated. + // See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask + // + // ```proto + // message MyFieldMask { + // // The `value` FieldMask shall not contain paths listed in `not_in`. + // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = { + // not_in: ["forbidden", "immutable", "c.a"] + // }]; + // } + // ``` + repeated string not_in = 3 [(predefined).cel = { + id: "field_mask.not_in" + expression: "!this.paths.all(p, !(p in getField(rules, 'not_in') || getField(rules, 'not_in').exists(f, p.startsWith(f+'.')))) ? 'value must not contain any paths in %s'.format([getField(rules, 'not_in')]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyFieldMask { + // google.protobuf.FieldMask value = 1 [ + // (buf.validate.field).field_mask.example = { paths: ["a", "b"] }, + // (buf.validate.field).field_mask.example = { paths: ["c.a", "d"] }, + // ]; + // } + // ``` + repeated google.protobuf.FieldMask example = 4 [(predefined).cel = { + id: "field_mask.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// TimestampRules describe the rules applied exclusively to the `google.protobuf.Timestamp` well-known type. +message TimestampRules { + // `const` dictates that this field, of the `google.protobuf.Timestamp` type, must exactly match the specified value. If the field value doesn't correspond to the specified timestamp, an error message will be generated. + // + // ```proto + // message MyTimestamp { + // // value must equal 2023-05-03T10:00:00Z + // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.const = {seconds: 1727998800}]; + // } + // ``` + optional google.protobuf.Timestamp const = 2 [(predefined).cel = { + id: "timestamp.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // requires the duration field value to be less than the specified value (field < value). If the field value doesn't meet the required conditions, an error message is generated. + // + // ```proto + // message MyDuration { + // // duration must be less than 'P3D' [duration.lt] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lt = { seconds: 259200 }]; + // } + // ``` + google.protobuf.Timestamp lt = 3 [(predefined).cel = { + id: "timestamp.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // requires the timestamp field value to be less than or equal to the specified value (field <= value). If the field value doesn't meet the required conditions, an error message is generated. + // + // ```proto + // message MyTimestamp { + // // timestamp must be less than or equal to '2023-05-14T00:00:00Z' [timestamp.lte] + // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.lte = { seconds: 1678867200 }]; + // } + // ``` + google.protobuf.Timestamp lte = 4 [(predefined).cel = { + id: "timestamp.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + + // `lt_now` specifies that this field, of the `google.protobuf.Timestamp` type, must be less than the current time. `lt_now` can only be used with the `within` rule. + // + // ```proto + // message MyTimestamp { + // // value must be less than now + // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.lt_now = true]; + // } + // ``` + bool lt_now = 7 [(predefined).cel = { + id: "timestamp.lt_now" + expression: "(rules.lt_now && this > now) ? 'value must be less than now' : ''" + }]; + } + oneof greater_than { + // `gt` requires the timestamp field value to be greater than the specified + // value (exclusive). If the value of `gt` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyTimestamp { + // // timestamp must be greater than '2023-01-01T00:00:00Z' [timestamp.gt] + // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gt = { seconds: 1672444800 }]; + // + // // timestamp must be greater than '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gt_lt] + // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gt: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }]; + // + // // timestamp must be greater than '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gt_lt_exclusive] + // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gt: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }]; + // } + // ``` + google.protobuf.Timestamp gt = 5 [ + (predefined).cel = { + id: "timestamp.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "timestamp.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the timestamp field value to be greater than or equal to the + // specified value (exclusive). If the value of `gte` is larger than a + // specified `lt` or `lte`, the range is reversed, and the field value + // must be outside the specified range. If the field value doesn't meet + // the required conditions, an error message is generated. + // + // ```proto + // message MyTimestamp { + // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' [timestamp.gte] + // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gte = { seconds: 1672444800 }]; + // + // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gte_lt] + // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gte: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }]; + // + // // timestamp must be greater than or equal to '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gte_lt_exclusive] + // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gte: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }]; + // } + // ``` + google.protobuf.Timestamp gte = 6 [ + (predefined).cel = { + id: "timestamp.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "timestamp.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "timestamp.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + + // `gt_now` specifies that this field, of the `google.protobuf.Timestamp` type, must be greater than the current time. `gt_now` can only be used with the `within` rule. + // + // ```proto + // message MyTimestamp { + // // value must be greater than now + // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.gt_now = true]; + // } + // ``` + bool gt_now = 8 [(predefined).cel = { + id: "timestamp.gt_now" + expression: "(rules.gt_now && this < now) ? 'value must be greater than now' : ''" + }]; + } + + // `within` specifies that this field, of the `google.protobuf.Timestamp` type, must be within the specified duration of the current time. If the field value isn't within the duration, an error message is generated. + // + // ```proto + // message MyTimestamp { + // // value must be within 1 hour of now + // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.within = {seconds: 3600}]; + // } + // ``` + optional google.protobuf.Duration within = 9 [(predefined).cel = { + id: "timestamp.within" + expression: "this < now-rules.within || this > now+rules.within ? 'value must be within %s of now'.format([rules.within]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyTimestamp { + // google.protobuf.Timestamp value = 1 [ + // (buf.validate.field).timestamp.example = { seconds: 1672444800 }, + // (buf.validate.field).timestamp.example = { seconds: 1672531200 }, + // ]; + // } + // ``` + repeated google.protobuf.Timestamp example = 10 [(predefined).cel = { + id: "timestamp.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// `Violations` is a collection of `Violation` messages. This message type is returned by +// Protovalidate when a proto message fails to meet the requirements set by the `Rule` validation rules. +// Each individual violation is represented by a `Violation` message. +message Violations { + // `violations` is a repeated field that contains all the `Violation` messages corresponding to the violations detected. + repeated Violation violations = 1; +} + +// `Violation` represents a single instance where a validation rule, expressed +// as a `Rule`, was not met. It provides information about the field that +// caused the violation, the specific rule that wasn't fulfilled, and a +// human-readable error message. +// +// For example, consider the following message: +// +// ```proto +// message User { +// int32 age = 1 [(buf.validate.field).cel = { +// id: "user.age", +// expression: "this < 18 ? 'User must be at least 18 years old' : ''", +// }]; +// } +// ``` +// +// It could produce the following violation: +// +// ```json +// { +// "ruleId": "user.age", +// "message": "User must be at least 18 years old", +// "field": { +// "elements": [ +// { +// "fieldNumber": 1, +// "fieldName": "age", +// "fieldType": "TYPE_INT32" +// } +// ] +// }, +// "rule": { +// "elements": [ +// { +// "fieldNumber": 23, +// "fieldName": "cel", +// "fieldType": "TYPE_MESSAGE", +// "index": "0" +// } +// ] +// } +// } +// ``` +message Violation { + // `field` is a machine-readable path to the field that failed validation. + // This could be a nested field, in which case the path will include all the parent fields leading to the actual field that caused the violation. + // + // For example, consider the following message: + // + // ```proto + // message Message { + // bool a = 1 [(buf.validate.field).required = true]; + // } + // ``` + // + // It could produce the following violation: + // + // ```textproto + // violation { + // field { element { field_number: 1, field_name: "a", field_type: 8 } } + // ... + // } + // ``` + optional FieldPath field = 5; + + // `rule` is a machine-readable path that points to the specific rule that failed validation. + // This will be a nested field starting from the FieldRules of the field that failed validation. + // For custom rules, this will provide the path of the rule, e.g. `cel[0]`. + // + // For example, consider the following message: + // + // ```proto + // message Message { + // bool a = 1 [(buf.validate.field).required = true]; + // bool b = 2 [(buf.validate.field).cel = { + // id: "custom_rule", + // expression: "!this ? 'b must be true': ''" + // }] + // } + // ``` + // + // It could produce the following violations: + // + // ```textproto + // violation { + // rule { element { field_number: 25, field_name: "required", field_type: 8 } } + // ... + // } + // violation { + // rule { element { field_number: 23, field_name: "cel", field_type: 11, index: 0 } } + // ... + // } + // ``` + optional FieldPath rule = 6; + + // `rule_id` is the unique identifier of the `Rule` that was not fulfilled. + // This is the same `id` that was specified in the `Rule` message, allowing easy tracing of which rule was violated. + optional string rule_id = 2; + + // `message` is a human-readable error message that describes the nature of the violation. + // This can be the default error message from the violated `Rule`, or it can be a custom message that gives more context about the violation. + optional string message = 3; + + // `for_key` indicates whether the violation was caused by a map key, rather than a value. + optional bool for_key = 4; + + reserved 1; + reserved "field_path"; +} + +// `FieldPath` provides a path to a nested protobuf field. +// +// This message provides enough information to render a dotted field path even without protobuf descriptors. +// It also provides enough information to resolve a nested field through unknown wire data. +message FieldPath { + // `elements` contains each element of the path, starting from the root and recursing downward. + repeated FieldPathElement elements = 1; +} + +// `FieldPathElement` provides enough information to nest through a single protobuf field. +// +// If the selected field is a map or repeated field, the `subscript` value selects a specific element from it. +// A path that refers to a value nested under a map key or repeated field index will have a `subscript` value. +// The `field_type` field allows unambiguous resolution of a field even if descriptors are not available. +message FieldPathElement { + // `field_number` is the field number this path element refers to. + optional int32 field_number = 1; + + // `field_name` contains the field name this path element refers to. + // This can be used to display a human-readable path even if the field number is unknown. + optional string field_name = 2; + + // `field_type` specifies the type of this field. When using reflection, this value is not needed. + // + // This value is provided to make it possible to traverse unknown fields through wire data. + // When traversing wire data, be mindful of both packed[1] and delimited[2] encoding schemes. + // + // [1]: https://protobuf.dev/programming-guides/encoding/#packed + // [2]: https://protobuf.dev/programming-guides/encoding/#groups + // + // N.B.: Although groups are deprecated, the corresponding delimited encoding scheme is not, and + // can be explicitly used in Protocol Buffers 2023 Edition. + optional google.protobuf.FieldDescriptorProto.Type field_type = 3; + + // `key_type` specifies the map key type of this field. This value is useful when traversing + // unknown fields through wire data: specifically, it allows handling the differences between + // different integer encodings. + optional google.protobuf.FieldDescriptorProto.Type key_type = 4; + + // `value_type` specifies map value type of this field. This is useful if you want to display a + // value inside unknown fields through wire data. + optional google.protobuf.FieldDescriptorProto.Type value_type = 5; + + // `subscript` contains a repeated index or map key, if this path element nests into a repeated or map field. + oneof subscript { + // `index` specifies a 0-based index into a repeated field. + uint64 index = 6; + + // `bool_key` specifies a map key of type bool. + bool bool_key = 7; + + // `int_key` specifies a map key of type int32, int64, sint32, sint64, sfixed32 or sfixed64. + int64 int_key = 8; + + // `uint_key` specifies a map key of type uint32, uint64, fixed32 or fixed64. + uint64 uint_key = 9; + + // `string_key` specifies a map key of type string. + string string_key = 10; + } +} diff --git a/modules/sync/bufbuild/protovalidate/cas/2d64e8ff856e1bf78a1289c24e868bdbe1ee2196f32b10bfe6ad8a743c7db99ba4be1a75c21d9f865ffa28464e11d339365b0f7937c75f7b308b3d5993cefd25 b/modules/sync/bufbuild/protovalidate/cas/2d64e8ff856e1bf78a1289c24e868bdbe1ee2196f32b10bfe6ad8a743c7db99ba4be1a75c21d9f865ffa28464e11d339365b0f7937c75f7b308b3d5993cefd25 new file mode 100644 index 00000000..57dcb8f0 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate/cas/2d64e8ff856e1bf78a1289c24e868bdbe1ee2196f32b10bfe6ad8a743c7db99ba4be1a75c21d9f865ffa28464e11d339365b0f7937c75f7b308b3d5993cefd25 @@ -0,0 +1,4 @@ +shake256:e702a95ca4516da9365b47a96282a3997660ecff5f614135d19a480ae7e9fb7fc0780efa034d133b95f5fe214a9fe4dd1cd65a9a9b6362db5f07792c0b699f38 LICENSE +shake256:26622ee52e0fe9e7daa0bd4cdc14bef2dc25f8bfacc79d077db09aebb218bb34d9911e4f525ef8571efba1db405d1d2855b2213e8aa42c6db1724ac9179d15e0 README.md +shake256:a63a855b2342eee56de5c3115d1c1e90c00274d805ee2b09bc6e5679f101b2f96c7a5cf554240e70b16ac5520483b47b9ebfbc9b95a4278e164f9eb312c5d883 buf.yaml +shake256:2751dd35f02933b1ae7a0394896014c1506c8aa3a737d3f65c81fb67f6332626db630c1c9291a579bb8b60d1eccd35064e19dffdbffd033dd0144bd228861503 buf/validate/validate.proto diff --git a/modules/sync/bufbuild/protovalidate/cas/e702a95ca4516da9365b47a96282a3997660ecff5f614135d19a480ae7e9fb7fc0780efa034d133b95f5fe214a9fe4dd1cd65a9a9b6362db5f07792c0b699f38 b/modules/sync/bufbuild/protovalidate/cas/e702a95ca4516da9365b47a96282a3997660ecff5f614135d19a480ae7e9fb7fc0780efa034d133b95f5fe214a9fe4dd1cd65a9a9b6362db5f07792c0b699f38 new file mode 100644 index 00000000..347d9fc9 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate/cas/e702a95ca4516da9365b47a96282a3997660ecff5f614135d19a480ae7e9fb7fc0780efa034d133b95f5fe214a9fe4dd1cd65a9a9b6362db5f07792c0b699f38 @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2023-2026 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. diff --git a/modules/sync/bufbuild/protovalidate/state.json b/modules/sync/bufbuild/protovalidate/state.json index 1ff8d2f8..1f957b65 100644 --- a/modules/sync/bufbuild/protovalidate/state.json +++ b/modules/sync/bufbuild/protovalidate/state.json @@ -279,6 +279,10 @@ { "name": "v1.1.0", "digest": "35b3d88f6b0fbf159d9eedfc2fbfa976490e6bca1d98914c1c71f29bfe2da6261fca56c057975b3e5c022b3234a0f2eea8e2d1b599a937c6c5d63d21201a9bc3" + }, + { + "name": "v1.1.1", + "digest": "2d64e8ff856e1bf78a1289c24e868bdbe1ee2196f32b10bfe6ad8a743c7db99ba4be1a75c21d9f865ffa28464e11d339365b0f7937c75f7b308b3d5993cefd25" } ] } \ No newline at end of file diff --git a/modules/sync/googleapis/cloud-run/state.json b/modules/sync/googleapis/cloud-run/state.json index cfee6f54..6f436012 100644 --- a/modules/sync/googleapis/cloud-run/state.json +++ b/modules/sync/googleapis/cloud-run/state.json @@ -659,6 +659,18 @@ { "name": "39bd091b055e331a4917143355ab7afa83b7130c", "digest": "04f36c3bc8a88d7f467cc05dad661f5d75877ae47b80c69c4e6d82bdf48194b146d81b76c0fc8b354bb862025e13ad152f6dcf9388fca55e334452234a86d3d8" + }, + { + "name": "af8a8d56476983207ac225892b38cc9bfbe744f1", + "digest": "04f36c3bc8a88d7f467cc05dad661f5d75877ae47b80c69c4e6d82bdf48194b146d81b76c0fc8b354bb862025e13ad152f6dcf9388fca55e334452234a86d3d8" + }, + { + "name": "a65054db0ad435ca30541a70d8ad32f162949d26", + "digest": "04f36c3bc8a88d7f467cc05dad661f5d75877ae47b80c69c4e6d82bdf48194b146d81b76c0fc8b354bb862025e13ad152f6dcf9388fca55e334452234a86d3d8" + }, + { + "name": "725496d32a359a40dd773995d3fda0342b440e15", + "digest": "04f36c3bc8a88d7f467cc05dad661f5d75877ae47b80c69c4e6d82bdf48194b146d81b76c0fc8b354bb862025e13ad152f6dcf9388fca55e334452234a86d3d8" } ] } \ No newline at end of file diff --git a/modules/sync/googleapis/googleapis/state.json b/modules/sync/googleapis/googleapis/state.json index ab1a6d84..a9c5eed0 100644 --- a/modules/sync/googleapis/googleapis/state.json +++ b/modules/sync/googleapis/googleapis/state.json @@ -21571,6 +21571,18 @@ { "name": "39bd091b055e331a4917143355ab7afa83b7130c", "digest": "d26c7c2fd95f0873761af33ca4a0c0d92c8577122b6feb74eb3b0a57ebe47a98ab24a209a0e91945ac4c77204e9da0c2de0020b2cedc27bdbcdea6c431eec69b" + }, + { + "name": "af8a8d56476983207ac225892b38cc9bfbe744f1", + "digest": "d26c7c2fd95f0873761af33ca4a0c0d92c8577122b6feb74eb3b0a57ebe47a98ab24a209a0e91945ac4c77204e9da0c2de0020b2cedc27bdbcdea6c431eec69b" + }, + { + "name": "a65054db0ad435ca30541a70d8ad32f162949d26", + "digest": "d26c7c2fd95f0873761af33ca4a0c0d92c8577122b6feb74eb3b0a57ebe47a98ab24a209a0e91945ac4c77204e9da0c2de0020b2cedc27bdbcdea6c431eec69b" + }, + { + "name": "725496d32a359a40dd773995d3fda0342b440e15", + "digest": "d26c7c2fd95f0873761af33ca4a0c0d92c8577122b6feb74eb3b0a57ebe47a98ab24a209a0e91945ac4c77204e9da0c2de0020b2cedc27bdbcdea6c431eec69b" } ] } \ No newline at end of file diff --git a/modules/sync/state.json b/modules/sync/state.json index 42cb60c6..512b41b7 100644 --- a/modules/sync/state.json +++ b/modules/sync/state.json @@ -6,11 +6,11 @@ }, { "module_name": "bufbuild/protovalidate", - "latest_reference": "v1.1.0" + "latest_reference": "v1.1.1" }, { "module_name": "bufbuild/protovalidate-testing", - "latest_reference": "v1.1.0" + "latest_reference": "v1.1.1" }, { "module_name": "bufbuild/reflect", @@ -42,11 +42,11 @@ }, { "module_name": "googleapis/cloud-run", - "latest_reference": "39bd091b055e331a4917143355ab7afa83b7130c" + "latest_reference": "725496d32a359a40dd773995d3fda0342b440e15" }, { "module_name": "googleapis/googleapis", - "latest_reference": "39bd091b055e331a4917143355ab7afa83b7130c" + "latest_reference": "725496d32a359a40dd773995d3fda0342b440e15" }, { "module_name": "googlechrome/lighthouse",