From 3a691e91adbb5fe74ed65c029faf630a99309428 Mon Sep 17 00:00:00 2001 From: unmultimedio <4431392+unmultimedio@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:05:28 +0000 Subject: [PATCH] Detected new managed modules references --- ...5bcbe4bcd7c9dd4f7594aecaed208f62df93b3ff86 | 166 + ...572a8b955fc288106f55cc0afe9c8f370aec63a24d | 7 + ...99a2cb1de584f723c8e73449329c110a46a44dbea1 | 90 + ...e71d23ba04c1cc4584b3e66c190719374948b672e4 | 37 + ...6c8812f6b1a59ed2c72975b7e088f3deaa26045c87 | 102 + ...6a88c2ff7a718c39a03b8278f043c6600cf98f8ebd | 27 + ...6dcd75f9ef0a0ceba55825eaad949f993bbe9b970a | 247 + ...6a843077dad425787f2bcf1dedea7c2e45373acbe4 | 79 + ...ac4d4c66e87c839ee9457fb914867ea9600da4b48b | 78 + ...9b747b1029b8132cfefda8b7539d28fdd9ee60b231 | 249 + ...810434d2304c0c4235e35f88a8d3617b1cc0702aef | 150 + ...8e506297350114109dc40cb7ee860ddfa5e35dd9b2 | 935 ++++ .../bufbuild/protovalidate-testing/state.json | 4 + ...a198782bec9644b8950b6237a21a89a8d80ca9b637 | 12 + ...5b9d84d3917198daa890a463232adc011962c3608a | 4 + ...d6b7511a18fe2e33745ec0b78860d6c5f8d6b3bf65 | 4897 +++++++++++++++++ ...6df16db80f0c12b12704815416ba0b6b4fdfbc7136 | 263 + .../sync/bufbuild/protovalidate/state.json | 4 + modules/sync/googleapis/googleapis/state.json | 16 + modules/sync/state.json | 6 +- 20 files changed, 7370 insertions(+), 3 deletions(-) create mode 100644 modules/sync/bufbuild/protovalidate-testing/cas/1e9cf90bf6de2600650ed239ef90ffc6472fb86fd16f7161b162fc74f6547f802e548c842eddb34dcd2a635bcbe4bcd7c9dd4f7594aecaed208f62df93b3ff86 create mode 100644 modules/sync/bufbuild/protovalidate-testing/cas/22f671e007e5cbd092bdf54c3538eb3d4a6ddd93958f25a792b482c334320e90f549bf2bbddf17225d34eb572a8b955fc288106f55cc0afe9c8f370aec63a24d create mode 100644 modules/sync/bufbuild/protovalidate-testing/cas/45e8ccdb0e9329cb573b6b2bb2f0d9182a828bbe662a49fe2f55f9523d854a738a49de110fe052f19b73f499a2cb1de584f723c8e73449329c110a46a44dbea1 create mode 100644 modules/sync/bufbuild/protovalidate-testing/cas/5ef0b4c031f6697d884d308ec8f7027cd7b32f5a2f6398a75a2461a7815798dc53e08720c34dd6bfecc5cde71d23ba04c1cc4584b3e66c190719374948b672e4 create mode 100644 modules/sync/bufbuild/protovalidate-testing/cas/8ff75722c54accfba78e7414e0cd3148d113e7ba7196f8c8caa08ac3d8d6250b9d7d9a80e9b5a3fc6defb66c8812f6b1a59ed2c72975b7e088f3deaa26045c87 create mode 100644 modules/sync/bufbuild/protovalidate-testing/cas/98eb95e18c56a98eb9525460ccbea6ad9bf8d956c3d3dc198b214ac23954b523b3c8a74a35a4d5330686e66a88c2ff7a718c39a03b8278f043c6600cf98f8ebd create mode 100644 modules/sync/bufbuild/protovalidate-testing/cas/b5aeeeceab319454cdff982117bbfb59dc8d3fbf1668f058c5d0d5eb407508486b748a55d0146c345511df6dcd75f9ef0a0ceba55825eaad949f993bbe9b970a create mode 100644 modules/sync/bufbuild/protovalidate-testing/cas/b88763ee84de2f1bf432d7666a49a2b4e73c82a9d7932280b86125a09dfb2abc7ce81538bd8a91a228206f6a843077dad425787f2bcf1dedea7c2e45373acbe4 create mode 100644 modules/sync/bufbuild/protovalidate-testing/cas/c078dc5bd5847d2ac3e7eb2415bb5c14677b01998dfd7f8193fb5f76ee3dbbbbdc01a835d9f3ad853790f6ac4d4c66e87c839ee9457fb914867ea9600da4b48b create mode 100644 modules/sync/bufbuild/protovalidate-testing/cas/c8976328d2a1aa50e40753384aaceea8811a938eb95eff97a667923fedfe200cb5bab6c3ecde181d7450fc9b747b1029b8132cfefda8b7539d28fdd9ee60b231 create mode 100644 modules/sync/bufbuild/protovalidate-testing/cas/e770d3124103badea345abae4af285795d41628b0d990e81d976b3f1b3493dc94a248e650714b0349502ab810434d2304c0c4235e35f88a8d3617b1cc0702aef create mode 100644 modules/sync/bufbuild/protovalidate-testing/cas/ed0268527cfc2bf87409392daa5430580fce686940361236ce736941b74b717f8a3d3edc985c4ab8544f3f8e506297350114109dc40cb7ee860ddfa5e35dd9b2 create mode 100644 modules/sync/bufbuild/protovalidate/cas/0f99164d5a3bb0bb6895258283315ab518ecd7c3c0500cde1f1bccb2bb3ba733dda1bb33921fb0e095cdaea198782bec9644b8950b6237a21a89a8d80ca9b637 create mode 100644 modules/sync/bufbuild/protovalidate/cas/39af97607624cfd20aada310ceb147ca39db00e5d464c94a803d7189fb09cf6787ba2bc978522ef0a2ee4a5b9d84d3917198daa890a463232adc011962c3608a create mode 100644 modules/sync/bufbuild/protovalidate/cas/409ecda9831af235f539e64aa88a8b28fe068d0bdbf686dabd380a19b3257704137cacbbe339b78c98e958d6b7511a18fe2e33745ec0b78860d6c5f8d6b3bf65 create mode 100644 modules/sync/bufbuild/protovalidate/cas/8ff3c07884a84f6a065530c0705bc3b9c8d66752265b11385e78ca63f5778c94879e20ba1b3e01fc93cc886df16db80f0c12b12704815416ba0b6b4fdfbc7136 diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/1e9cf90bf6de2600650ed239ef90ffc6472fb86fd16f7161b162fc74f6547f802e548c842eddb34dcd2a635bcbe4bcd7c9dd4f7594aecaed208f62df93b3ff86 b/modules/sync/bufbuild/protovalidate-testing/cas/1e9cf90bf6de2600650ed239ef90ffc6472fb86fd16f7161b162fc74f6547f802e548c842eddb34dcd2a635bcbe4bcd7c9dd4f7594aecaed208f62df93b3ff86 new file mode 100644 index 00000000..2f7891c8 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/1e9cf90bf6de2600650ed239ef90ffc6472fb86fd16f7161b162fc74f6547f802e548c842eddb34dcd2a635bcbe4bcd7c9dd4f7594aecaed208f62df93b3ff86 @@ -0,0 +1,166 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package buf.validate.conformance.cases; + +import "buf/validate/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_UNPOPULATED + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/22f671e007e5cbd092bdf54c3538eb3d4a6ddd93958f25a792b482c334320e90f549bf2bbddf17225d34eb572a8b955fc288106f55cc0afe9c8f370aec63a24d b/modules/sync/bufbuild/protovalidate-testing/cas/22f671e007e5cbd092bdf54c3538eb3d4a6ddd93958f25a792b482c334320e90f549bf2bbddf17225d34eb572a8b955fc288106f55cc0afe9c8f370aec63a24d new file mode 100644 index 00000000..e31ea4b7 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/22f671e007e5cbd092bdf54c3538eb3d4a6ddd93958f25a792b482c334320e90f549bf2bbddf17225d34eb572a8b955fc288106f55cc0afe9c8f370aec63a24d @@ -0,0 +1,7 @@ +# Testing + +Many `protovalidate` tests are defined as protobuf messages, this provides a +language agnostic way to ensure all `protovalidate` components and +implementations have the same features and support without regression. + +Discover more [here](https://github.com/bufbuild/protovalidate/tree/main/tools/protovalidate-conformance). diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/45e8ccdb0e9329cb573b6b2bb2f0d9182a828bbe662a49fe2f55f9523d854a738a49de110fe052f19b73f499a2cb1de584f723c8e73449329c110a46a44dbea1 b/modules/sync/bufbuild/protovalidate-testing/cas/45e8ccdb0e9329cb573b6b2bb2f0d9182a828bbe662a49fe2f55f9523d854a738a49de110fe052f19b73f499a2cb1de584f723c8e73449329c110a46a44dbea1 new file mode 100644 index 00000000..150c6799 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/45e8ccdb0e9329cb573b6b2bb2f0d9182a828bbe662a49fe2f55f9523d854a738a49de110fe052f19b73f499a2cb1de584f723c8e73449329c110a46a44dbea1 @@ -0,0 +1,90 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message IgnoreEmptyProto3Scalar { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyProto3OptionalScalar { + optional int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyProto3Message { + optional Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (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_UNPOPULATED, + (buf.validate.field).int32.gt = 0 + ]; + } +} + +message IgnoreEmptyProto3Repeated { + repeated int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message IgnoreEmptyProto3Map { + map val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).map.min_pairs = 3 + ]; +} + +message IgnoreEmptyRepeatedItems { + repeated int32 val = 1 [(buf.validate.field).repeated.items = { + ignore: IGNORE_IF_UNPOPULATED + int32: {gt: 0} + }]; +} + +message IgnoreEmptyMapPairs { + map val = 1 [ + (buf.validate.field).map.keys = { + ignore: IGNORE_IF_UNPOPULATED + string: {min_len: 3} + }, + (buf.validate.field).map.values = { + ignore: IGNORE_IF_UNPOPULATED + int32: {gt: 0} + } + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/5ef0b4c031f6697d884d308ec8f7027cd7b32f5a2f6398a75a2461a7815798dc53e08720c34dd6bfecc5cde71d23ba04c1cc4584b3e66c190719374948b672e4 b/modules/sync/bufbuild/protovalidate-testing/cas/5ef0b4c031f6697d884d308ec8f7027cd7b32f5a2f6398a75a2461a7815798dc53e08720c34dd6bfecc5cde71d23ba04c1cc4584b3e66c190719374948b672e4 new file mode 100644 index 00000000..4d8c9490 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/5ef0b4c031f6697d884d308ec8f7027cd7b32f5a2f6398a75a2461a7815798dc53e08720c34dd6bfecc5cde71d23ba04c1cc4584b3e66c190719374948b672e4 @@ -0,0 +1,37 @@ +shake256:8f88503768991dcc77b5a39a4a8d3374c99f4f0f69fb9e58a383fa238b20645190dc4570817b8ab9bbd83e90d063d151048137ef8c6bdb51ea797f7c6f41cfba LICENSE +shake256:22f671e007e5cbd092bdf54c3538eb3d4a6ddd93958f25a792b482c334320e90f549bf2bbddf17225d34eb572a8b955fc288106f55cc0afe9c8f370aec63a24d README.md +shake256:98eb95e18c56a98eb9525460ccbea6ad9bf8d956c3d3dc198b214ac23954b523b3c8a74a35a4d5330686e66a88c2ff7a718c39a03b8278f043c6600cf98f8ebd buf.yaml +shake256:dc07664bb57896d98642cd4f2e32ec850fb415bd52c99485b3656d0eb3855432ca119df1704b310d6c2e118e1942aa942a0cc4016d5ae1a690382cd837e7ca88 buf/validate/conformance/cases/bool.proto +shake256:8ff75722c54accfba78e7414e0cd3148d113e7ba7196f8c8caa08ac3d8d6250b9d7d9a80e9b5a3fc6defb66c8812f6b1a59ed2c72975b7e088f3deaa26045c87 buf/validate/conformance/cases/bytes.proto +shake256:e4d2a127c9619c0f56de1b3102cd15e947c02b1c2df3c1bb34d804340184d49363c4460ba4a8f5235af5a70782b2566989317d4efe27a42db3cc4962ec7cd3bc buf/validate/conformance/cases/custom_constraints/custom_constraints.proto +shake256:6725a5f04c2640cc50e9986cb7a538a05af713f96d6f716af726f3fcc3b9f0ab026db17fd6da1e0e0b1f278be88aa5653f95e5f8eb585cef0c29e8bb6aeea034 buf/validate/conformance/cases/enums.proto +shake256:f27bc7f3fc084c84cd163322bdaa850cf923b9efaaa6ecca3466f51f0898fafe9a6fa00cd4b3af071382c30921b3f19e1fe6fb7c35f50069f92a7a4f84364697 buf/validate/conformance/cases/filename-with-dash.proto +shake256:c078dc5bd5847d2ac3e7eb2415bb5c14677b01998dfd7f8193fb5f76ee3dbbbbdc01a835d9f3ad853790f6ac4d4c66e87c839ee9457fb914867ea9600da4b48b buf/validate/conformance/cases/ignore_empty_proto2.proto +shake256:45e8ccdb0e9329cb573b6b2bb2f0d9182a828bbe662a49fe2f55f9523d854a738a49de110fe052f19b73f499a2cb1de584f723c8e73449329c110a46a44dbea1 buf/validate/conformance/cases/ignore_empty_proto3.proto +shake256:e770d3124103badea345abae4af285795d41628b0d990e81d976b3f1b3493dc94a248e650714b0349502ab810434d2304c0c4235e35f88a8d3617b1cc0702aef buf/validate/conformance/cases/ignore_empty_proto_editions.proto +shake256:1518de9df4730277e5109a92ca0f5b3a3d979de94bc404d10093a181c1b968ad9979a37be548f3dc3caa591dadae025ab59df4d212313ccf0de246e4b64d77f7 buf/validate/conformance/cases/ignore_proto2.proto +shake256:b5aeeeceab319454cdff982117bbfb59dc8d3fbf1668f058c5d0d5eb407508486b748a55d0146c345511df6dcd75f9ef0a0ceba55825eaad949f993bbe9b970a buf/validate/conformance/cases/ignore_proto3.proto +shake256:1329fa737f9d05ccd41b87803c44f5c7a513c060b552d2cab26741ecbff8438e593b6d66aebff840e88fc6058c3d912b18a955c28cca0f49dbd500c8188b46fb buf/validate/conformance/cases/ignore_proto_editions.proto +shake256:8b1bee8d27493c60da734d3e16a620c8520f6126a682bd5764b7d861c08cd916315cd01e2fa6e30925e8fa3a809f3c0b77048dcad82b5c14c6e8d61ba23627d3 buf/validate/conformance/cases/kitchen_sink.proto +shake256:b88763ee84de2f1bf432d7666a49a2b4e73c82a9d7932280b86125a09dfb2abc7ce81538bd8a91a228206f6a843077dad425787f2bcf1dedea7c2e45373acbe4 buf/validate/conformance/cases/maps.proto +shake256:98e5d516b88da150d62f3aaa5e2f1eda4cd48cdb6300933f7efcb7337b82388cdb0061980b4dec00f35c0eb92426283e07e673bbdd5f81168c3767704747daba buf/validate/conformance/cases/messages.proto +shake256:ed0268527cfc2bf87409392daa5430580fce686940361236ce736941b74b717f8a3d3edc985c4ab8544f3f8e506297350114109dc40cb7ee860ddfa5e35dd9b2 buf/validate/conformance/cases/numbers.proto +shake256:749cd37bcb4b2ae2c20e858d97e7b5a7ab1cb69bc8a7512bea77160810c3e6d114d6c424047364a8ae9f2a823ab6e51f69f1825d5a9f0ec81371806ccae2b672 buf/validate/conformance/cases/oneofs.proto +shake256:50633a57b483850fb64e06c1bcd0eb545c8a359a940dd4d92ef1e14232e05ab6f8194e89f1b5fadab5722f1b2f7eb240036b034018ea3437c23039eab1e9db5c buf/validate/conformance/cases/other_package/embed.proto +shake256:1a324ec70b9778966d351c543c70f73ad942c82ea3c8ed24ec10f26ff6d4676f440f68a4c49d5be1b16cbd2b78dd89be559109866853742cf607619fe1672563 buf/validate/conformance/cases/predefined_rules_proto2.proto +shake256:52e8ba9cc75e6d9bbb6f48260eac0aa081732f3a8465e906d7be70a55c3dcbe6912b6e05ee9b2f961c415463b42cf9c558955611f440e4901b3c26bda89b99ab buf/validate/conformance/cases/predefined_rules_proto3.proto +shake256:90c883c4a724a8634456bc03bdad9da5e45fd4741afb50d795e545d143ae8634865ecc78d4f1772cf4887ad3fa4e44bbf39d70322a201a80fc37c67bb34e7d77 buf/validate/conformance/cases/predefined_rules_proto_editions.proto +shake256:1e9cf90bf6de2600650ed239ef90ffc6472fb86fd16f7161b162fc74f6547f802e548c842eddb34dcd2a635bcbe4bcd7c9dd4f7594aecaed208f62df93b3ff86 buf/validate/conformance/cases/repeated.proto +shake256:c52e29912f8335b7318194fcc214b6b129e7b059cef19261857d83ffd7b2168739cfba67ce8ce774f2f96242c4098cd9d0304864c500498ea735f60496d04a9f buf/validate/conformance/cases/required_field_proto2.proto +shake256:e5d32ac0c0f9c64c783394e73b57f771b1cb637451575e006d324fba3d45ade5f072b111aeef260c07d17ce5390c1d5355ea79443e41dc26af0a51496e30b6ba buf/validate/conformance/cases/required_field_proto3.proto +shake256:e04bde1938bc544bdfa90ce41138fb9af0272c362898baf0c1e3db3f6c80fa9c75a83b546861deff98bd8fa489f1231da4e02b46937168f847be98b58bdc3240 buf/validate/conformance/cases/required_field_proto_editions.proto +shake256:c8976328d2a1aa50e40753384aaceea8811a938eb95eff97a667923fedfe200cb5bab6c3ecde181d7450fc9b747b1029b8132cfefda8b7539d28fdd9ee60b231 buf/validate/conformance/cases/strings.proto +shake256:5bd92ab2145d3a6c301948b75af7b69d367f70b172fb29538d192c51e0516ee48d3db820a76f4ebcbbffc6ea1baf3b590399da2b160adb648458079080360b07 buf/validate/conformance/cases/subdirectory/in_subdirectory.proto +shake256:a742e6490da44a38f9977f2fabd38d92696dd8316720d9d8cd4d7adb2bcc09cc433dffa56112c569995e65649275bbc1a6e32c09a4cdfcce47a4c71371abb88d buf/validate/conformance/cases/wkt_any.proto +shake256:d6933c869e2bbb0fa1845a2ea4877d797857be804710a1b02a2989fc07d9655762312442112f207d86eb5e784200ba05b648386ad759452b04f60887de647867 buf/validate/conformance/cases/wkt_duration.proto +shake256:e0fa2c82ea25392f2e28d3345e1a7210c9fb82367795cbe2d5c191fa643171efec2d3b9752214d97fc936194428bf7d37fc365eadd0ecb369e888984902264cf buf/validate/conformance/cases/wkt_nested.proto +shake256:9d2d7856a4444798802bd7c45ff53f0f240f860fcaa23a5589ea9b3382d8467e4ca24d8fac61513e1a8e5fc7e0caa94c4f32c8dad00919cc5e1715a2b85e9a5d buf/validate/conformance/cases/wkt_timestamp.proto +shake256:7a4f30de82964fa0a8524111af262f3973d77cab6deb7c46c3880008109983c31ea1bff52fd9d2edecc4dddc8fff427713fc974def5b35155d9a728398c14f4b buf/validate/conformance/cases/wkt_wrappers.proto +shake256:5ed1054c3b0604ddb721929f2f9e0acc882f9d838a1f7e1e8312ebfe51b9a80e7937654f668e0a3b783340e64c331f540cf496f93ffd83f53dbdbcb14f9d9efa buf/validate/conformance/cases/yet_another_package/embed2.proto +shake256:79e93df83102a1a220d7c9e56a2f7fcc276b03b6ca7bced951965ce5d6060daaa77c04ca5a75fe53b14125c846dadd05808679fdc000e20f20b8a1620eadac4b buf/validate/conformance/harness/harness.proto +shake256:160efbb6958bcedfbf354970512f2485182bcb58b4c2bbdf2dc8798a79bc6c4ffe57c9c0cc6b52ac73c97a83c5c7550f5275f01d1bd44b127e3d4ab81ba23554 buf/validate/conformance/harness/results.proto diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/8ff75722c54accfba78e7414e0cd3148d113e7ba7196f8c8caa08ac3d8d6250b9d7d9a80e9b5a3fc6defb66c8812f6b1a59ed2c72975b7e088f3deaa26045c87 b/modules/sync/bufbuild/protovalidate-testing/cas/8ff75722c54accfba78e7414e0cd3148d113e7ba7196f8c8caa08ac3d8d6250b9d7d9a80e9b5a3fc6defb66c8812f6b1a59ed2c72975b7e088f3deaa26045c87 new file mode 100644 index 00000000..04be285b --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/8ff75722c54accfba78e7414e0cd3148d113e7ba7196f8c8caa08ac3d8d6250b9d7d9a80e9b5a3fc6defb66c8812f6b1a59ed2c72975b7e088f3deaa26045c87 @@ -0,0 +1,102 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message 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_UNPOPULATED + ]; +} +message BytesExample { + bytes val = 1 [(buf.validate.field).bytes.example = "\x99"]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/98eb95e18c56a98eb9525460ccbea6ad9bf8d956c3d3dc198b214ac23954b523b3c8a74a35a4d5330686e66a88c2ff7a718c39a03b8278f043c6600cf98f8ebd b/modules/sync/bufbuild/protovalidate-testing/cas/98eb95e18c56a98eb9525460ccbea6ad9bf8d956c3d3dc198b214ac23954b523b3c8a74a35a4d5330686e66a88c2ff7a718c39a03b8278f043c6600cf98f8ebd new file mode 100644 index 00000000..b2ebd030 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/98eb95e18c56a98eb9525460ccbea6ad9bf8d956c3d3dc198b214ac23954b523b3c8a74a35a4d5330686e66a88c2ff7a718c39a03b8278f043c6600cf98f8ebd @@ -0,0 +1,27 @@ +version: v1 +name: buf.build/bufbuild/protovalidate-testing +deps: + - buf.build/bufbuild/protovalidate +build: + excludes: + - tests +breaking: + use: + - FILE + ignore: + - buf/validate/conformance +lint: + use: + - STANDARD + except: + - PROTOVALIDATE + ignore_only: + ENUM_NO_ALLOW_ALIAS: + - buf/validate/conformance/cases/enums.proto + FILE_LOWER_SNAKE_CASE: + - buf/validate/conformance/cases/filename-with-dash.proto + IMPORT_USED: + - buf/validate/conformance/cases/subdirectory/in_subdirectory.proto + - buf/validate/conformance/cases/filename-with-dash.proto + PACKAGE_VERSION_SUFFIX: + - buf/validate/conformance diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/b5aeeeceab319454cdff982117bbfb59dc8d3fbf1668f058c5d0d5eb407508486b748a55d0146c345511df6dcd75f9ef0a0ceba55825eaad949f993bbe9b970a b/modules/sync/bufbuild/protovalidate-testing/cas/b5aeeeceab319454cdff982117bbfb59dc8d3fbf1668f058c5d0d5eb407508486b748a55d0146c345511df6dcd75f9ef0a0ceba55825eaad949f993bbe9b970a new file mode 100644 index 00000000..5580dfb1 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/b5aeeeceab319454cdff982117bbfb59dc8d3fbf1668f058c5d0d5eb407508486b748a55d0146c345511df6dcd75f9ef0a0ceba55825eaad949f993bbe9b970a @@ -0,0 +1,247 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message Proto3ScalarOptionalIgnoreUnspecified { + optional int32 val = 1 [(buf.validate.field).int32.gt = 0]; +} + +message Proto3ScalarOptionalIgnoreEmpty { + optional int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).int32.gt = 0 + ]; +} + +message Proto3ScalarOptionalIgnoreDefault { + optional int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE, + (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_UNPOPULATED, + (buf.validate.field).int32.gt = 0 + ]; +} + +message Proto3ScalarIgnoreDefault { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE, + (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_UNPOPULATED, + (buf.validate.field).cel = { + id: "proto3.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + optional string val = 1; + } +} + +message Proto3MessageOptionalIgnoreDefault { + optional Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE, + (buf.validate.field).cel = { + id: "proto3.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + optional string val = 1; + } +} + +message 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_UNPOPULATED, + (buf.validate.field).cel = { + id: "proto3.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + optional string val = 1; + } +} + +message Proto3MessageIgnoreDefault { + Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE, + (buf.validate.field).cel = { + id: "proto3.message.ignore.empty" + message: "foobar" + expression: "this.val == 'foo'" + } + ]; + message Msg { + optional string val = 1; + } +} + +message Proto3OneofIgnoreUnspecified { + oneof o { + int32 val = 1 [(buf.validate.field).int32.gt = 0]; + } +} + +message Proto3OneofIgnoreEmpty { + oneof o { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).int32.gt = 0 + ]; + } +} + +message Proto3OneofIgnoreDefault { + oneof o { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE, + (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_UNPOPULATED, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message Proto3RepeatedIgnoreDefault { + repeated int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE, + (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_UNPOPULATED, + (buf.validate.field).map.min_pairs = 3 + ]; +} + +message Proto3MapIgnoreDefault { + map val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE, + (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_UNPOPULATED, + (buf.validate.field).repeated.items.int32.gt = 0 + ]; +} + +message Proto3RepeatedItemIgnoreDefault { + repeated int32 val = 1 [ + (buf.validate.field).repeated.items.ignore = IGNORE_IF_DEFAULT_VALUE, + (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_UNPOPULATED, + (buf.validate.field).map.keys.int32.gt = 0 + ]; +} + +message Proto3MapKeyIgnoreDefault { + map val = 1 [ + (buf.validate.field).map.keys.ignore = IGNORE_IF_DEFAULT_VALUE, + (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_UNPOPULATED, + (buf.validate.field).map.values.int32.gt = 0 + ]; +} + +message Proto3MapValueIgnoreDefault { + map val = 1 [ + (buf.validate.field).map.values.ignore = IGNORE_IF_DEFAULT_VALUE, + (buf.validate.field).map.values.int32.gt = 0 + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/b88763ee84de2f1bf432d7666a49a2b4e73c82a9d7932280b86125a09dfb2abc7ce81538bd8a91a228206f6a843077dad425787f2bcf1dedea7c2e45373acbe4 b/modules/sync/bufbuild/protovalidate-testing/cas/b88763ee84de2f1bf432d7666a49a2b4e73c82a9d7932280b86125a09dfb2abc7ce81538bd8a91a228206f6a843077dad425787f2bcf1dedea7c2e45373acbe4 new file mode 100644 index 00000000..c2c64fee --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/b88763ee84de2f1bf432d7666a49a2b4e73c82a9d7932280b86125a09dfb2abc7ce81538bd8a91a228206f6a843077dad425787f2bcf1dedea7c2e45373acbe4 @@ -0,0 +1,79 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message 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_UNPOPULATED + ]; +} + +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/c078dc5bd5847d2ac3e7eb2415bb5c14677b01998dfd7f8193fb5f76ee3dbbbbdc01a835d9f3ad853790f6ac4d4c66e87c839ee9457fb914867ea9600da4b48b b/modules/sync/bufbuild/protovalidate-testing/cas/c078dc5bd5847d2ac3e7eb2415bb5c14677b01998dfd7f8193fb5f76ee3dbbbbdc01a835d9f3ad853790f6ac4d4c66e87c839ee9457fb914867ea9600da4b48b new file mode 100644 index 00000000..5e443025 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/c078dc5bd5847d2ac3e7eb2415bb5c14677b01998dfd7f8193fb5f76ee3dbbbbdc01a835d9f3ad853790f6ac4d4c66e87c839ee9457fb914867ea9600da4b48b @@ -0,0 +1,78 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto2"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message IgnoreEmptyProto2ScalarOptional { + optional int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyProto2ScalarOptionalWithDefault { + optional int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).int32.gt = 0, + default = 42 + ]; +} + +message IgnoreEmptyProto2ScalarRequired { + required int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyProto2Message { + optional Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (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_UNPOPULATED, + (buf.validate.field).int32.gt = 0 + ]; + } +} + +message IgnoreEmptyProto2Repeated { + repeated int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message IgnoreEmptyProto2Map { + map val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).map.min_pairs = 3 + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/c8976328d2a1aa50e40753384aaceea8811a938eb95eff97a667923fedfe200cb5bab6c3ecde181d7450fc9b747b1029b8132cfefda8b7539d28fdd9ee60b231 b/modules/sync/bufbuild/protovalidate-testing/cas/c8976328d2a1aa50e40753384aaceea8811a938eb95eff97a667923fedfe200cb5bab6c3ecde181d7450fc9b747b1029b8132cfefda8b7539d28fdd9ee60b231 new file mode 100644 index 00000000..c1383c5a --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/c8976328d2a1aa50e40753384aaceea8811a938eb95eff97a667923fedfe200cb5bab6c3ecde181d7450fc9b747b1029b8132cfefda8b7539d28fdd9ee60b231 @@ -0,0 +1,249 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message 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 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_UNPOPULATED + ]; +} +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/e770d3124103badea345abae4af285795d41628b0d990e81d976b3f1b3493dc94a248e650714b0349502ab810434d2304c0c4235e35f88a8d3617b1cc0702aef b/modules/sync/bufbuild/protovalidate-testing/cas/e770d3124103badea345abae4af285795d41628b0d990e81d976b3f1b3493dc94a248e650714b0349502ab810434d2304c0c4235e35f88a8d3617b1cc0702aef new file mode 100644 index 00000000..92a960c1 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/e770d3124103badea345abae4af285795d41628b0d990e81d976b3f1b3493dc94a248e650714b0349502ab810434d2304c0c4235e35f88a8d3617b1cc0702aef @@ -0,0 +1,150 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +edition = "2023"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message IgnoreEmptyEditionsScalarExplicitPresence { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyEditionsScalarExplicitPresenceWithDefault { + int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).int32.gt = 0, + default = 42 + ]; +} + +message IgnoreEmptyEditionsScalarImplicitPresence { + int32 val = 1 [ + features.field_presence = IMPLICIT, + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyEditionsScalarLegacyRequired { + int32 val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).int32.gt = 0 + ]; +} + +message IgnoreEmptyEditionsScalarLegacyRequiredWithDefault { + int32 val = 1 [ + features.field_presence = LEGACY_REQUIRED, + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).int32.gt = 0, + default = 42 + ]; +} + +message IgnoreEmptyEditionsMessageExplicitPresence { + Msg val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (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_UNPOPULATED, + (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_UNPOPULATED, + (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_UNPOPULATED, + (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_UNPOPULATED, + (buf.validate.field).int32.gt = 0 + ]; + } +} + +message IgnoreEmptyEditionsRepeated { + repeated int32 val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message IgnoreEmptyEditionsRepeatedExpanded { + repeated int32 val = 1 [ + features.repeated_field_encoding = EXPANDED, + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).repeated.min_items = 3 + ]; +} + +message IgnoreEmptyEditionsMap { + map val = 1 [ + (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED, + (buf.validate.field).map.min_pairs = 3 + ]; +} diff --git a/modules/sync/bufbuild/protovalidate-testing/cas/ed0268527cfc2bf87409392daa5430580fce686940361236ce736941b74b717f8a3d3edc985c4ab8544f3f8e506297350114109dc40cb7ee860ddfa5e35dd9b2 b/modules/sync/bufbuild/protovalidate-testing/cas/ed0268527cfc2bf87409392daa5430580fce686940361236ce736941b74b717f8a3d3edc985c4ab8544f3f8e506297350114109dc40cb7ee860ddfa5e35dd9b2 new file mode 100644 index 00000000..0eb8352a --- /dev/null +++ b/modules/sync/bufbuild/protovalidate-testing/cas/ed0268527cfc2bf87409392daa5430580fce686940361236ce736941b74b717f8a3d3edc985c4ab8544f3f8e506297350114109dc40cb7ee860ddfa5e35dd9b2 @@ -0,0 +1,935 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package buf.validate.conformance.cases; + +import "buf/validate/validate.proto"; + +message 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_UNPOPULATED + ]; +} + +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_UNPOPULATED + ]; +} + +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_UNPOPULATED + ]; +} + +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_UNPOPULATED + ]; +} +message Int64BigConstraints { + // 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_UNPOPULATED + ]; +} + +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_UNPOPULATED + ]; +} + +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_UNPOPULATED + ]; +} + +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_UNPOPULATED + ]; +} +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_UNPOPULATED + ]; +} + +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_UNPOPULATED + ]; +} + +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_UNPOPULATED + ]; +} + +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_UNPOPULATED + ]; +} + +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/state.json b/modules/sync/bufbuild/protovalidate-testing/state.json index e8b8fab0..dac1f6fc 100644 --- a/modules/sync/bufbuild/protovalidate-testing/state.json +++ b/modules/sync/bufbuild/protovalidate-testing/state.json @@ -183,6 +183,10 @@ { "name": "v0.9.0", "digest": "741ca0756fda41ca42e9844cda51d72d98372cc1d55886450868a6930685cae8b07176743ceebc68c1213269de074ce5f153e06b0ebf2a59628f8d2b3ad17bfd" + }, + { + "name": "v0.10.0", + "digest": "5ef0b4c031f6697d884d308ec8f7027cd7b32f5a2f6398a75a2461a7815798dc53e08720c34dd6bfecc5cde71d23ba04c1cc4584b3e66c190719374948b672e4" } ] } \ No newline at end of file diff --git a/modules/sync/bufbuild/protovalidate/cas/0f99164d5a3bb0bb6895258283315ab518ecd7c3c0500cde1f1bccb2bb3ba733dda1bb33921fb0e095cdaea198782bec9644b8950b6237a21a89a8d80ca9b637 b/modules/sync/bufbuild/protovalidate/cas/0f99164d5a3bb0bb6895258283315ab518ecd7c3c0500cde1f1bccb2bb3ba733dda1bb33921fb0e095cdaea198782bec9644b8950b6237a21a89a8d80ca9b637 new file mode 100644 index 00000000..737a97c3 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate/cas/0f99164d5a3bb0bb6895258283315ab518ecd7c3c0500cde1f1bccb2bb3ba733dda1bb33921fb0e095cdaea198782bec9644b8950b6237a21a89a8d80ca9b637 @@ -0,0 +1,12 @@ +version: v1 +name: buf.build/bufbuild/protovalidate +breaking: + use: + - FILE +lint: + use: + - STANDARD + ignore_only: + PACKAGE_VERSION_SUFFIX: + - buf/validate + allow_comment_ignores: true diff --git a/modules/sync/bufbuild/protovalidate/cas/39af97607624cfd20aada310ceb147ca39db00e5d464c94a803d7189fb09cf6787ba2bc978522ef0a2ee4a5b9d84d3917198daa890a463232adc011962c3608a b/modules/sync/bufbuild/protovalidate/cas/39af97607624cfd20aada310ceb147ca39db00e5d464c94a803d7189fb09cf6787ba2bc978522ef0a2ee4a5b9d84d3917198daa890a463232adc011962c3608a new file mode 100644 index 00000000..ce5fdfa4 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate/cas/39af97607624cfd20aada310ceb147ca39db00e5d464c94a803d7189fb09cf6787ba2bc978522ef0a2ee4a5b9d84d3917198daa890a463232adc011962c3608a @@ -0,0 +1,4 @@ +shake256:8f88503768991dcc77b5a39a4a8d3374c99f4f0f69fb9e58a383fa238b20645190dc4570817b8ab9bbd83e90d063d151048137ef8c6bdb51ea797f7c6f41cfba LICENSE +shake256:8ff3c07884a84f6a065530c0705bc3b9c8d66752265b11385e78ca63f5778c94879e20ba1b3e01fc93cc886df16db80f0c12b12704815416ba0b6b4fdfbc7136 README.md +shake256:0f99164d5a3bb0bb6895258283315ab518ecd7c3c0500cde1f1bccb2bb3ba733dda1bb33921fb0e095cdaea198782bec9644b8950b6237a21a89a8d80ca9b637 buf.yaml +shake256:409ecda9831af235f539e64aa88a8b28fe068d0bdbf686dabd380a19b3257704137cacbbe339b78c98e958d6b7511a18fe2e33745ec0b78860d6c5f8d6b3bf65 buf/validate/validate.proto diff --git a/modules/sync/bufbuild/protovalidate/cas/409ecda9831af235f539e64aa88a8b28fe068d0bdbf686dabd380a19b3257704137cacbbe339b78c98e958d6b7511a18fe2e33745ec0b78860d6c5f8d6b3bf65 b/modules/sync/bufbuild/protovalidate/cas/409ecda9831af235f539e64aa88a8b28fe068d0bdbf686dabd380a19b3257704137cacbbe339b78c98e958d6b7511a18fe2e33745ec0b78860d6c5f8d6b3bf65 new file mode 100644 index 00000000..e021c276 --- /dev/null +++ b/modules/sync/bufbuild/protovalidate/cas/409ecda9831af235f539e64aa88a8b28fe068d0bdbf686dabd380a19b3257704137cacbbe339b78c98e958d6b7511a18fe2e33745ec0b78860d6c5f8d6b3bf65 @@ -0,0 +1,4897 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto2"; + +package buf.validate; + +import "google/protobuf/descriptor.proto"; +import "google/protobuf/duration.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 MessageConstraints 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 OneofConstraints 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 FieldConstraints field = 1159; + + // Specifies predefined rules. When extending a standard constraint 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 PredefinedConstraints predefined = 1160; +} + +// `Constraint` represents a validation rule written in the Common Expression +// Language (CEL) syntax. Each Constraint includes a unique identifier, an +// optional error message, and the CEL expression to evaluate. For more +// information on CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md). +// +// ```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 Constraint { + // `id` is a string that serves as a machine-readable name for this Constraint. + // 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 Constraint 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; +} + +// MessageConstraints represents validation rules that are applied to the entire message. +// It includes disabling options and a list of Constraint messages representing Common Expression Language (CEL) validation rules. +message MessageConstraints { + // `disabled` is a boolean flag that, when set to true, nullifies any validation rules for this message. + // This includes any fields within the message that would otherwise support validation. + // + // ```proto + // message MyMessage { + // // validation will be bypassed for this message + // option (buf.validate.message).disabled = true; + // } + // ``` + optional bool disabled = 1; + + // `cel` is a repeated field of type Constraint. Each Constraint specifies a validation rule to be applied to this message. + // These constraints are written in Common Expression Language (CEL) syntax. For more information on + // CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md). + // + // + // ```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 Constraint cel = 3; +} + +// The `OneofConstraints` message type enables you to manage constraints for +// oneof fields in your protobuf messages. +message OneofConstraints { + // If `required` is true, exactly one field of the oneof must be present. A + // validation error is returned if no fields in the oneof are present. The + // field itself may still be a default value; further constraints + // 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; +} + +// FieldConstraints encapsulates the rules for each type of field. Depending on +// the field, the correct set should be used to ensure proper validations. +message FieldConstraints { + // `cel` is a repeated field used to represent a textual expression + // in the Common Expression Language (CEL) syntax. For more information on + // CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md). + // + // ```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 Constraint cel = 23; + // If `required` is true, the field must be populated. A populated field can be + // described as "serialized in the wire format," which includes: + // + // - the following "nullable" fields must be explicitly set to be considered populated: + // - singular message fields (whose fields may be unpopulated/default values) + // - member fields of a oneof (may be their default value) + // - proto3 optional fields (may be their default value) + // - proto2 scalar fields (both optional and required) + // - proto3 scalar fields must be non-zero to be considered populated + // - repeated and map fields must be non-empty to be considered populated + // + // ```proto + // message MyMessage { + // // The field `value` must be set to a non-null value. + // optional MyOtherMessage value = 1 [(buf.validate.field).required = true]; + // } + // ``` + optional bool required = 25; + // Skip validation on the field if its value matches the specified criteria. + // See Ignore enum for details. + // + // ```proto + // message UpdateRequest { + // // The uri rule only applies if the field is populated and not an empty + // // string. + // optional string url = 1 [ + // (buf.validate.field).ignore = IGNORE_IF_DEFAULT_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; + TimestampRules timestamp = 22; + } +} + +// PredefinedConstraints are custom constraints that can be re-used with +// multiple fields. +message PredefinedConstraints { + // `cel` is a repeated field used to represent a textual expression + // in the Common Expression Language (CEL) syntax. For more information on + // CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md). + // + // ```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 Constraint cel = 1; + + reserved 24, 26; + reserved + "skipped" + "ignore_empty" +; +} + +// Specifies how FieldConstraints.ignore behaves. See the documentation for +// FieldConstraints.required for definitions of "populated" and "nullable". +enum Ignore { + // Validation is only skipped if it's an unpopulated nullable fields. + // + // ```proto + // syntax="proto3"; + // + // message Request { + // // The uri rule applies to any value, including the empty string. + // string foo = 1 [ + // (buf.validate.field).string.uri = true + // ]; + // + // // The uri rule only applies if the field is set, including if it's + // // set to the empty string. + // optional string bar = 2 [ + // (buf.validate.field).string.uri = true + // ]; + // + // // The min_items rule always applies, even if the list is empty. + // repeated string baz = 3 [ + // (buf.validate.field).repeated.min_items = 3 + // ]; + // + // // The custom CEL rule applies only if the field is set, including if + // // it's the "zero" value of that message. + // SomeMessage quux = 4 [ + // (buf.validate.field).cel = {/* ... */} + // ]; + // } + // ``` + IGNORE_UNSPECIFIED = 0; + + // Validation is skipped if the field is unpopulated. This rule is redundant + // if the field is already nullable. + // + // ```proto + // syntax="proto3 + // + // message Request { + // // The uri rule applies only if the value is not the empty string. + // string foo = 1 [ + // (buf.validate.field).string.uri = true, + // (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED + // ]; + // + // // IGNORE_IF_UNPOPULATED is equivalent to IGNORE_UNSPECIFIED in this + // // case: the uri rule only applies if the field is set, including if + // // it's set to the empty string. + // optional string bar = 2 [ + // (buf.validate.field).string.uri = true, + // (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED + // ]; + // + // // The min_items rule only applies if the list has at least one item. + // repeated string baz = 3 [ + // (buf.validate.field).repeated.min_items = 3, + // (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED + // ]; + // + // // IGNORE_IF_UNPOPULATED is equivalent to IGNORE_UNSPECIFIED in this + // // case: the custom CEL rule applies only if the field is set, including + // // if it's the "zero" value of that message. + // SomeMessage quux = 4 [ + // (buf.validate.field).cel = {/* ... */}, + // (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED + // ]; + // } + // ``` + IGNORE_IF_UNPOPULATED = 1; + + // Validation is skipped if the field is unpopulated or if it is a nullable + // field populated with its default value. This is typically the zero or + // empty value, but proto2 scalars support custom defaults. For messages, the + // default is a non-null message with all its fields unpopulated. + // + // ```proto + // syntax="proto3 + // + // message Request { + // // IGNORE_IF_DEFAULT_VALUE is equivalent to IGNORE_IF_UNPOPULATED in + // // this case; the uri rule applies only if the value is not the empty + // // string. + // string foo = 1 [ + // (buf.validate.field).string.uri = true, + // (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE + // ]; + // + // // The uri rule only applies if the field is set to a value other than + // // the empty string. + // optional string bar = 2 [ + // (buf.validate.field).string.uri = true, + // (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE + // ]; + // + // // IGNORE_IF_DEFAULT_VALUE is equivalent to IGNORE_IF_UNPOPULATED in + // // this case; the min_items rule only applies if the list has at least + // // one item. + // repeated string baz = 3 [ + // (buf.validate.field).repeated.min_items = 3, + // (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE + // ]; + // + // // The custom CEL rule only applies if the field is set to a value other + // // than an empty message (i.e., fields are unpopulated). + // SomeMessage quux = 4 [ + // (buf.validate.field).cel = {/* ... */}, + // (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE + // ]; + // } + // ``` + // + // This rule is affected by proto2 custom default values: + // + // ```proto + // syntax="proto2"; + // + // message Request { + // // The gt rule only applies if the field is set and it's value is not + // the default (i.e., not -42). The rule even applies if the field is set + // to zero since the default value differs. + // optional int32 value = 1 [ + // default = -42, + // (buf.validate.field).int32.gt = 0, + // (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE + // ]; + // } + IGNORE_IF_DEFAULT_VALUE = 2; + + // The validation rules of this field will be skipped and not evaluated. This + // is useful for situations that necessitate turning off the rules of a field + // containing a message that may not make sense in the current context, or to + // temporarily disable constraints during development. + // + // ```proto + // message MyMessage { + // // The field's rules will always be ignored, including any validation's + // // on value's fields. + // MyOtherMessage value = 1 [ + // (buf.validate.field).ignore = IGNORE_ALWAYS]; + // } + // ``` + IGNORE_ALWAYS = 3; + + reserved + "IGNORE_EMPTY" + "IGNORE_DEFAULT" +; +} + +// FloatRules describes the constraints 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 != rules.const ? 'value must equal %s'.format([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] + // repeated 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 dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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] + // repeated 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 constraints. `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 = "Infinity" + // ]; + // } + // ``` + repeated float example = 9 [(predefined).cel = { + id: "float.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// DoubleRules describes the constraints 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 != rules.const ? 'value must equal %s'.format([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] + // repeated 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 dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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] + // repeated 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 constraints. `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 = "Infinity" + // ]; + // } + // ``` + repeated double example = 9 [(predefined).cel = { + id: "double.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// Int32Rules describes the constraints 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 != rules.const ? 'value must equal %s'.format([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] + // repeated int32 value = 1 (buf.validate.field).int32 = { in: [1, 2, 3] }; + // } + // ``` + repeated int32 in = 6 [(predefined).cel = { + id: "int32.in" + expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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] + // repeated 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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// Int64Rules describes the constraints 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 != rules.const ? 'value must equal %s'.format([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] + // repeated int64 value = 1 (buf.validate.field).int64 = { in: [1, 2, 3] }; + // } + // ``` + repeated int64 in = 6 [(predefined).cel = { + id: "int64.in" + expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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] + // repeated 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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// UInt32Rules describes the constraints 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 != rules.const ? 'value must equal %s'.format([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] + // repeated uint32 value = 1 (buf.validate.field).uint32 = { in: [1, 2, 3] }; + // } + // ``` + repeated uint32 in = 6 [(predefined).cel = { + id: "uint32.in" + expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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] + // repeated 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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// UInt64Rules describes the constraints 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 != rules.const ? 'value must equal %s'.format([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] + // repeated uint64 value = 1 (buf.validate.field).uint64 = { in: [1, 2, 3] }; + // } + // ``` + repeated uint64 in = 6 [(predefined).cel = { + id: "uint64.in" + expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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] + // repeated 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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// SInt32Rules describes the constraints 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 != rules.const ? 'value must equal %s'.format([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] + // repeated sint32 value = 1 (buf.validate.field).sint32 = { in: [1, 2, 3] }; + // } + // ``` + repeated sint32 in = 6 [(predefined).cel = { + id: "sint32.in" + expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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] + // repeated 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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// SInt64Rules describes the constraints 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 != rules.const ? 'value must equal %s'.format([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] + // repeated sint64 value = 1 (buf.validate.field).sint64 = { in: [1, 2, 3] }; + // } + // ``` + repeated sint64 in = 6 [(predefined).cel = { + id: "sint64.in" + expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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] + // repeated 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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// Fixed32Rules describes the constraints 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 != rules.const ? 'value must equal %s'.format([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] + // repeated fixed32 value = 1 (buf.validate.field).fixed32 = { in: [1, 2, 3] }; + // } + // ``` + repeated fixed32 in = 6 [(predefined).cel = { + id: "fixed32.in" + expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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] + // repeated 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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// Fixed64Rules describes the constraints 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 != rules.const ? 'value must equal %s'.format([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] + // repeated fixed64 value = 1 (buf.validate.field).fixed64 = { in: [1, 2, 3] }; + // } + // ``` + repeated fixed64 in = 6 [(predefined).cel = { + id: "fixed64.in" + expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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] + // repeated 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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// SFixed32Rules describes the constraints 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 != rules.const ? 'value must equal %s'.format([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] + // repeated sfixed32 value = 1 (buf.validate.field).sfixed32 = { in: [1, 2, 3] }; + // } + // ``` + repeated sfixed32 in = 6 [(predefined).cel = { + id: "sfixed32.in" + expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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] + // repeated 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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// SFixed64Rules describes the constraints 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 != rules.const ? 'value must equal %s'.format([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] + // repeated sfixed64 value = 1 (buf.validate.field).sfixed64 = { in: [1, 2, 3] }; + // } + // ``` + repeated sfixed64 in = 6 [(predefined).cel = { + id: "sfixed64.in" + expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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] + // repeated 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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// BoolRules describes the constraints 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 != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// StringRules describes the constraints 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 != rules.const ? 'value must equal `%s`'.format([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"] + // repeated 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 dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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"] + // repeated 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 constraints against common string + // patterns + oneof well_known { + // `email` specifies that the field value must be a valid email address + // (addr-spec only) as defined by [RFC 5322](https://tools.ietf.org/html/rfc5322#section-3.4.1). + // 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 as defined by [RFC 1034](https://tools.ietf.org/html/rfc1034#section-3.5). This constraint doesn't support + // internationalized domain names (IDNs). 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, without surrounding square brackets for IPv6 addresses. + // 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. 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, without surrounding square brackets. 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, + // absolute URI as defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3). If the field value isn't a valid, + // absolute 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 + // as defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3) and may be either relative or absolute. 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_ref = true]; + // } + // ``` + bool uri_ref = 18 [(predefined).cel = { + id: "string.uri_ref" + message: "value must be a valid URI" + expression: "!rules.uri_ref || this.isUriRef()" + }]; + + // `address` specifies that the field value must be either a valid hostname + // as defined by [RFC 1034](https://tools.ietf.org/html/rfc1034#section-3.5) + // (which doesn't support internationalized domain names or IDNs) or a valid + // IP (v4 or v6). 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://tools.ietf.org/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://tools.ietf.org/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. 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. + // 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. + // 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. + // If the field value isn't a valid IP prefix, an error message will be + // generated. The prefix must have all zeros for the masked bits of the prefix (e.g., + // `127.0.0.0/16`, not `127.0.0.1/16`). + // + // ```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. If the field value isn't a valid IPv4 prefix, an error message + // will be generated. The prefix must have all zeros for the masked bits of + // the prefix (e.g., `127.0.0.0/16`, not `127.0.0.1/16`). + // + // ```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. + // If the field value is not a valid IPv6 prefix, an error message will be + // generated. The prefix must have all zeros for the masked bits of the prefix + // (e.g., `2001:db8::/48`, not `2001:db8::1/48`). + // + // ```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 the field value must be a valid host and port + // pair. The host must be a valid hostname or IP address while the port + // must be in the range of 0-65535, inclusive. IPv6 addresses must be delimited + // with square brackets (e.g., `[::1]:1234`). + 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 != ''" + } + ]; + + // `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://tools.ietf.org/html/rfc7230#section-3.2) | + // | KNOWN_REGEX_HTTP_HEADER_VALUE | 2 | HTTP header value as defined by [RFC 7230](https://tools.ietf.org/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://tools.ietf.org/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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// WellKnownRegex contain some well-known patterns. +enum KnownRegex { + KNOWN_REGEX_UNSPECIFIED = 0; + + // HTTP header name as defined by [RFC 7230](https://tools.ietf.org/html/rfc7230#section-3.2). + KNOWN_REGEX_HTTP_HEADER_NAME = 1; + + // HTTP header value as defined by [RFC 7230](https://tools.ietf.org/html/rfc7230#section-3.2.4). + KNOWN_REGEX_HTTP_HEADER_VALUE = 2; +} + +// BytesRules describe the constraints 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 != rules.const ? 'value must be %x'.format([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. + // + // ```protobuf + // 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. + // + // ```protobuf + // 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: "dyn(rules)['in'].size() > 0 && !(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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 constraints 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 constraint, 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 constraint, 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 constraint, 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" + } + ]; + } + + // `example` specifies values that the field may have. These values SHOULD + // conform to other constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// EnumRules describe the constraints 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 != rules.const ? 'value must equal %s'.format([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 dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// RepeatedRules describe the constraints 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 constraint 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 constraints to be applied to each item + // in the field. Even for repeated message fields, validation is executed + // against each item unless skip is explicitly specified. + // + // ```proto + // message MyRepeated { + // // The items in the field `value` must follow the specified constraints. + // repeated string value = 1 [(buf.validate.field).repeated.items = { + // string: { + // min_len: 3 + // max_len: 10 + // } + // }]; + // } + // ``` + optional FieldConstraints items = 4; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// MapRules describe the constraints 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 constraints to be applied to each key in the field. + // + // ```proto + // message MyMap { + // // The keys in the field `value` must follow the specified constraints. + // map value = 1 [(buf.validate.field).map.keys = { + // string: { + // min_len: 3 + // max_len: 10 + // } + // }]; + // } + // ``` + optional FieldConstraints keys = 4; + + //Specifies the constraints to be applied to the value of each key in the + // field. Message values will still have their validations evaluated unless + //skip is specified here. + // + // ```proto + // message MyMap { + // // The values in the field `value` must follow the specified constraints. + // map value = 1 [(buf.validate.field).map.values = { + // string: { + // min_len: 5 + // max_len: 20 + // } + // }]; + // } + // ``` + optional FieldConstraints values = 5; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// AnyRules describe constraints 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 field `value` 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 constraints 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 != rules.const ? 'value must equal %s'.format([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 dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// TimestampRules describe the constraints 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 != rules.const ? 'value must equal %s'.format([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 constraints. `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 in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field constraints that can then be + // set on the field options of other fields to apply field constraints. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + 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 `Constraint` 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 `Constraint`, was not met. It provides information about the field that +// caused the violation, the specific constraint that wasn't fulfilled, and a +// human-readable error message. +// +// ```json +// { +// "fieldPath": "bar", +// "constraintId": "foo.bar", +// "message": "bar must be greater than 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 constraint rule that failed validation. + // This will be a nested field starting from the FieldConstraints of the field that failed validation. + // For custom constraints, this will provide the path of the constraint, 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_constraint", + // 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; + + // `constraint_id` is the unique identifier of the `Constraint` that was not fulfilled. + // This is the same `id` that was specified in the `Constraint` message, allowing easy tracing of which rule was violated. + optional string constraint_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 `Constraint`, 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/8ff3c07884a84f6a065530c0705bc3b9c8d66752265b11385e78ca63f5778c94879e20ba1b3e01fc93cc886df16db80f0c12b12704815416ba0b6b4fdfbc7136 b/modules/sync/bufbuild/protovalidate/cas/8ff3c07884a84f6a065530c0705bc3b9c8d66752265b11385e78ca63f5778c94879e20ba1b3e01fc93cc886df16db80f0c12b12704815416ba0b6b4fdfbc7136 new file mode 100644 index 00000000..fd56161a --- /dev/null +++ b/modules/sync/bufbuild/protovalidate/cas/8ff3c07884a84f6a065530c0705bc3b9c8d66752265b11385e78ca63f5778c94879e20ba1b3e01fc93cc886df16db80f0c12b12704815416ba0b6b4fdfbc7136 @@ -0,0 +1,263 @@ +![The Buf logo](https://raw.githubusercontent.com/bufbuild/protovalidate/main/.github/buf-logo.svg) + +# protovalidate + +[![CI](https://github.com/bufbuild/protovalidate/actions/workflows/ci.yaml/badge.svg?branch=main)][ci] +[![Slack](https://img.shields.io/badge/Slack-Buf-%23e01563)][slack] +[![BSR](https://img.shields.io/badge/BSR-Module-0C65EC)][buf-mod] + +`protovalidate` is a series of libraries designed to validate Protobuf messages at +runtime based on user-defined validation rules. Powered by Google's Common +Expression Language ([CEL][cel-spec]), it provides a +flexible and efficient foundation for defining and evaluating custom validation +rules. The primary goal of `protovalidate` is to help developers ensure data +consistency and integrity across the network without requiring generated code. + +> [!NOTE] +> `protovalidate` is the spiritual successor to [protoc-gen-validate][pgv]. It does not require any code +> generation and supports custom constraints. +> +> We recommend that new and existing projects transition to using `protovalidate` instead of `protoc-gen-validate`. +> +> Read [our blog post][announce] if you want to learn more about the limitations of `protoc-gen-validate` and +> how we have designed `protovalidate` to be better. + +## What is this repository? + +This repository is the core of the `protovalidate` project. It contains: + +- [The API definition][validate-proto]: used to describe validation constraints +- [Documentation][docs]: how to apply `protovalidate` effectively +- [Migration tooling][migrate]: incrementally migrate from `protoc-gen-validate` +- [Examples][examples]: example `.proto` files using `protovalidate` +- [Conformance testing utilities][conformance]: for acceptance testing of `protovalidate` implementations + +### Implementations + +Runtime implementations of `protovalidate` can be found in their own repositories: + +- Go: [`protovalidate-go`][pv-go] (beta release) +- C++: [`protovalidate-cc`][pv-cc] (beta release) +- Java: [`protovalidate-java`][pv-java] (beta release) +- Python: [`protovalidate-python`][pv-python] (beta release) +- TypeScript: `protovalidate-ts` (coming soon) + +Interested in adding support for another language? Check out our +[Contributing Guidelines][contributing]. + +## Usage + +### Import protovalidate + +To define constraints within your Protobuf messages, +import `buf/validate/validate.proto` into your `.proto` files: + +```protobuf +syntax = "proto3"; + +package my.package; + +import "buf/validate/validate.proto"; +``` + +#### Build with [`buf`][buf] + +Add a dependency on [`buf.build/bufbuild/protovalidate`][buf-mod] to your +module's [`buf.yaml`][buf-deps]: + +```yaml +version: v1 +# +deps: + - buf.build/bufbuild/protovalidate +# +``` + +After modifying your `buf.yaml`, don't forget to run `buf mod update` to ensure +your dependencies are up-to-date. + +#### Build with `protoc` + +Add an import path (`-I` flag) pointing to the contents of the `proto/protovalidate` +directory to your invocation of `protoc`: + +```shell +protoc \ + -I ./vendor/protovalidate/proto/protovalidate \ + # +``` + +### Implementing validation constraints + +Validation constraints can be enforced using the `buf.validate` Protobuf package. The rules are specified directly in the `.proto` files. + +Let's consider a few examples: + +1. **Scalar field validation:** For a basic `User` message, we can enforce constraints such as a minimum length for the user's name. + + ```protobuf + syntax = "proto3"; + + import "buf/validate/validate.proto"; + + message User { + // User's name, must be at least 1 character long. + string name = 1 [(buf.validate.field).string.min_len = 1]; + } + ``` + +2. **Map field validation:** For a `Product` message with a map of item quantities, we can ensure that all quantities are positive. + + ```protobuf + syntax = "proto3"; + + import "buf/validate/validate.proto"; + + message Product { + // Map of item quantities, all quantities must be positive. + map item_quantities = 1 [(buf.validate.field).map.values.int32.gt = 0]; + } + ``` + +3. **Well-known type (WKT) validation:** For the `User` message, we can add a constraint to ensure the `created_at` timestamp is in the past. + + ```protobuf + syntax = "proto3"; + + import "google/protobuf/timestamp.proto"; + import "buf/validate/validate.proto"; + + message User { + // User's creation date must be in the past. + google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.lt_now = true]; + } + ``` + +For more advanced or custom constraints, `protovalidate` allows for CEL expressions that can incorporate information across fields. + +1. **Field-level expressions:** We can enforce that a products' `price`, sent as a string, includes a currency symbol like "$" or "£". We want to ensure that the price is positive and the currency symbol is valid. + + ```protobuf + syntax = "proto3"; + + import "buf/validate/validate.proto"; + + message Product { + string price = 1 [(buf.validate.field).cel = { + id: "product.price", + message: "Price must be positive and include a valid currency symbol ($ or £)", + expression: "(this.startsWith('$') || this.startsWith('£')) && double(this.substring(1)) > 0" + }]; + } + ``` + +2. **Message-level expressions:** For a `Transaction` message, we can use a message-level CEL expression to ensure that the `delivery_date` is always after the `purchase_date`. + + ```protobuf + syntax = "proto3"; + + import "google/protobuf/timestamp.proto"; + import "buf/validate/validate.proto"; + + message Transaction { + google.protobuf.Timestamp purchase_date = 1; + google.protobuf.Timestamp delivery_date = 2; + + option (buf.validate.message).cel = { + id: "transaction.delivery_date", + message: "Delivery date must be after purchase date", + expression: "this.delivery_date > this.purchase_date" + }; + } + ``` + +3. **Producing an error message in the expression:** We can produce custom error messages directly in the CEL expressions. In this example, if the `age` is less than 18, the CEL expression will evaluate to the error message string. + + ```protobuf + syntax = "proto3"; + + import "buf/validate/validate.proto"; + + message User { + int32 age = 1 [(buf.validate.field).cel = { + id: "user.age", + expression: "this < 18 ? 'User must be at least 18 years old': ''" + }]; + } + ``` + +Check out [`examples`][examples] for examples on both standard constraints and custom CEL constraints. + +### Validate Messages + +Once the messages are annotated with constraints, use one of the [supported language libraries](#implementations) to validate; no additional code generation necessary. + +## Documentation + +`protovalidate` provides a robust framework for validating Protobuf messages by +enforcing standard and custom constraints on various data types, and offering +detailed error information when validation violations occur. For a detailed +overview of all its components, the supported constraints, and how to use them +effectively, please refer to our [comprehensive documentation](docs/README.md). +The key components include: + +- [**Standard Constraints**](https://github.com/bufbuild/protovalidate/blob/main/docs/standard-constraints.md): `protovalidate` + supports a wide range of standard + constraints for all field types as well as special functionality for the + Protobuf Well-Known-Types. You can apply these constraints to your Protobuf + messages to ensure they meet certain common conditions. + +- [**Custom Constraints**](https://github.com/bufbuild/protovalidate/blob/main/docs/custom-constraints.md): With Google's Common + Expression Language (CEL), + `protovalidate` allows you to create complex, custom constraints to + handle unique validation scenarios that aren't covered by the standard + constraints at both the field and message level. + +- [**Error Handling**](https://github.com/bufbuild/protovalidate/blob/main/docs/README.md#errors): When a violation + occurs, `protovalidate`provides + detailed error information to help you quickly identify the source and fix for + an issue. + +### protoc-gen-validate + +`protovalidate` is the spiritual successor to [`protoc-gen-validate`][pgv], offering +all of the same functionality present in the original plugin, without the need +for custom code generation, and the new ability to describe complex constraints in CEL. + +`protovalidate`'s constraints very closely emulate those +in `protoc-gen-validate` to ensure an easy transition for developers. To +migrate from `protoc-gen-validate` to `protovalidate`, use the +provided [migration tool][migration-tool] to +incrementally upgrade your `.proto` files. + +## Ecosystem + +- [Buf][buf] +- [CEL Specification][cel-spec] + +## Legal + +Offered under the [Apache 2 license][license]. + +[announce]: https://buf.build/blog/protoc-gen-validate-v1-and-v2/ +[buf-deps]: https://buf.build/docs/configuration/v1/buf-yaml/#deps +[buf-mod]: https://buf.build/bufbuild/protovalidate +[buf]: https://buf.build +[cel-spec]: https://github.com/google/cel-spec +[ci]: https://github.com/bufbuild/protovalidate/actions/workflows/ci.yaml +[conformance]: https://github.com/bufbuild/protovalidate/blob/main/docs/conformance.md +[contributing]: https://github.com/bufbuild/protovalidate/blob/main/.github/CONTRIBUTING.md +[docs]: https://github.com/bufbuild/protovalidate/blob/main/docs +[examples]: https://github.com/bufbuild/protovalidate/tree/main/examples +[file-bug]: https://github.com/bufbuild/protovalidate/issues/new?assignees=&labels=Bug&template=bug_report.md&title=%5BBUG%5D +[file-feature-request]: https://github.com/bufbuild/protovalidate/issues/new?assignees=&labels=Feature&template=feature_request.md&title=%5BFeature+Request%5D +[license]: https://github.com/bufbuild/protovalidate/blob/main/LICENSE +[migrate]: https://buf.build/docs/migration-guides/migrate-from-protoc-gen-validate/ +[migration-tool]: https://github.com/bufbuild/protovalidate/blob/main/tools/protovalidate-migrate +[pgv]: https://github.com/bufbuild/protoc-gen-validate +[pv-go]: https://github.com/bufbuild/protovalidate-go +[pv-cc]: https://github.com/bufbuild/protovalidate-cc +[pv-java]: https://github.com/bufbuild/protovalidate-java +[pv-python]: https://github.com/bufbuild/protovalidate-python +[slack]: https://buf.build/links/slack +[validate-proto]: https://buf.build/bufbuild/protovalidate/docs/main:buf.validate diff --git a/modules/sync/bufbuild/protovalidate/state.json b/modules/sync/bufbuild/protovalidate/state.json index 9b2f10ac..d3352fbc 100644 --- a/modules/sync/bufbuild/protovalidate/state.json +++ b/modules/sync/bufbuild/protovalidate/state.json @@ -187,6 +187,10 @@ { "name": "v0.9.0", "digest": "5563c6e7f982cd21b3068b860e55aff6c3c0ecb494e7b4f7d1f36327db3490a1540b3c6615af9f9dfab8c5b4aee819a6941eda16f970dfd0d310c1a622244d19" + }, + { + "name": "v0.10.0", + "digest": "39af97607624cfd20aada310ceb147ca39db00e5d464c94a803d7189fb09cf6787ba2bc978522ef0a2ee4a5b9d84d3917198daa890a463232adc011962c3608a" } ] } \ No newline at end of file diff --git a/modules/sync/googleapis/googleapis/state.json b/modules/sync/googleapis/googleapis/state.json index 4ff168ef..315b830a 100644 --- a/modules/sync/googleapis/googleapis/state.json +++ b/modules/sync/googleapis/googleapis/state.json @@ -15831,6 +15831,22 @@ { "name": "280725e991516d4a0f136268faf5aa6d32d21b54", "digest": "93dbe51c27606999eef918360df509485a4d272e79aaed6d0016940379a9b06d316fc5228b7b50cca94bb310f34c5fc5955ce7474f655f0d0a224c4121dda3c1" + }, + { + "name": "331a41aa9b3a0631abe4e1eb5dae67ab9c8bb043", + "digest": "93dbe51c27606999eef918360df509485a4d272e79aaed6d0016940379a9b06d316fc5228b7b50cca94bb310f34c5fc5955ce7474f655f0d0a224c4121dda3c1" + }, + { + "name": "2a3db2e19f48a139db9f40278c0217df110add9b", + "digest": "93dbe51c27606999eef918360df509485a4d272e79aaed6d0016940379a9b06d316fc5228b7b50cca94bb310f34c5fc5955ce7474f655f0d0a224c4121dda3c1" + }, + { + "name": "2e899eed4464394e6298e3c4cfd4a40d83a6b1ba", + "digest": "93dbe51c27606999eef918360df509485a4d272e79aaed6d0016940379a9b06d316fc5228b7b50cca94bb310f34c5fc5955ce7474f655f0d0a224c4121dda3c1" + }, + { + "name": "d57f2c114b2d1d3db7fa71a1333d72129f8fd1ae", + "digest": "93dbe51c27606999eef918360df509485a4d272e79aaed6d0016940379a9b06d316fc5228b7b50cca94bb310f34c5fc5955ce7474f655f0d0a224c4121dda3c1" } ] } \ No newline at end of file diff --git a/modules/sync/state.json b/modules/sync/state.json index bc19a18c..d1c727d7 100644 --- a/modules/sync/state.json +++ b/modules/sync/state.json @@ -6,11 +6,11 @@ }, { "module_name": "bufbuild/protovalidate", - "latest_reference": "v0.9.0" + "latest_reference": "v0.10.0" }, { "module_name": "bufbuild/protovalidate-testing", - "latest_reference": "v0.9.0" + "latest_reference": "v0.10.0" }, { "module_name": "bufbuild/reflect", @@ -42,7 +42,7 @@ }, { "module_name": "googleapis/googleapis", - "latest_reference": "280725e991516d4a0f136268faf5aa6d32d21b54" + "latest_reference": "d57f2c114b2d1d3db7fa71a1333d72129f8fd1ae" }, { "module_name": "googlechrome/lighthouse",