From 176e9e101f8a9de11ed6daf305497c482933b02b Mon Sep 17 00:00:00 2001 From: Charith Ellawala Date: Mon, 15 Apr 2024 08:57:42 +0100 Subject: [PATCH] chore: Update protobufs (#42) Signed-off-by: Charith Ellawala --- proto/buf.lock | 22 +- proto/defs/buf/validate/expression.proto | 92 + proto/defs/buf/validate/priv/private.proto | 41 + proto/defs/buf/validate/validate.proto | 3812 +++++++++++++++++ proto/defs/cerbos/audit/v1/audit.proto | 8 +- proto/defs/cerbos/effect/v1/effect.proto | 2 +- proto/defs/cerbos/engine/v1/engine.proto | 52 +- proto/defs/cerbos/policy/v1/policy.proto | 368 +- proto/defs/cerbos/request/v1/request.proto | 151 +- proto/defs/cerbos/response/v1/response.proto | 113 +- proto/defs/cerbos/schema/v1/schema.proto | 10 +- proto/defs/cerbos/svc/v1/svc.proto | 15 +- .../defs/cerbos/telemetry/v1/telemetry.proto | 2 +- proto/defs/google/api/field_behavior.proto | 14 + .../options/openapiv2.proto | 6 +- proto/defs/validate/validate.proto | 862 ---- src/genpb/buf.validate.r#priv.rs | 18 + src/genpb/buf.validate.rs | 2808 ++++++++++++ src/genpb/cerbos.audit.v1.rs | 11 + src/genpb/cerbos.policy.v1.rs | 46 +- src/genpb/cerbos.request.v1.rs | 12 + src/genpb/cerbos.response.v1.rs | 34 + src/genpb/cerbos.svc.v1.rs | 32 + src/genpb/google.api.rs | 15 + ...pc.gateway.protoc_gen_openapiv2.options.rs | 6 +- 25 files changed, 7452 insertions(+), 1100 deletions(-) create mode 100644 proto/defs/buf/validate/expression.proto create mode 100644 proto/defs/buf/validate/priv/private.proto create mode 100644 proto/defs/buf/validate/validate.proto delete mode 100644 proto/defs/validate/validate.proto create mode 100644 src/genpb/buf.validate.r#priv.rs create mode 100644 src/genpb/buf.validate.rs diff --git a/proto/buf.lock b/proto/buf.lock index 5ce09b4..e70be26 100644 --- a/proto/buf.lock +++ b/proto/buf.lock @@ -1,23 +1,23 @@ # Generated by buf. DO NOT EDIT. version: v1 deps: + - remote: buf.build + owner: bufbuild + repository: protovalidate + commit: e097f827e65240ac9fd4b1158849a8fc + digest: shake256:f19252436fd9ded945631e2ffaaed28247a92c9015ccf55ae99db9fb3d9600c4fdb00fd2d3bd7701026ec2fd4715c5129e6ae517c25a59ba690020cfe80bf8ad - remote: buf.build owner: cerbos repository: cerbos-api - commit: 8be1b70686fe48e1945513b9fa966b66 - digest: shake256:f99342ea1db4efcddbfe5476040579abc50d3be65a5a36a5b003563e85b135edab0911f0e116362fe667d5d1ec5135aed46319857db15179dabcf6a25ee8c729 - - remote: buf.build - owner: envoyproxy - repository: protoc-gen-validate - commit: 6607b10f00ed4a3d98f906807131c44a - digest: shake256:acc7b2ededb2f88d296862943a003b157bdb68ec93ed13dcd8566b2d06e47993ea6daf12013b9655658aaf6bbdb141cf65bfe400ce2870f4654b0a5b45e57c09 + commit: fa3315d53601494abb35a95f1232c313 + digest: shake256:b2712ba97cdbf03c5111261ed409b5d77cf0c9aa2336cfb6a4f78a22f75598e3ff30efba74429cb91ef1edad3eed653f1a4a1f2741671d434846ef6db4faeb05 - remote: buf.build owner: googleapis repository: googleapis - commit: cc916c31859748a68fd229a3c8d7a2e8 - digest: shake256:469b049d0eb04203d5272062636c078decefc96fec69739159c25d85349c50c34c7706918a8b216c5c27f76939df48452148cff8c5c3ae77fa6ba5c25c1b8bf8 + commit: b30c5775bfb3485d9da2e87b26590ac9 + digest: shake256:9d0caaf056949a0e1c883b9849d8a2fa66e22f18a2a48f867d1a8c700aa22abee50ad3ef0d8171637457cadc43c584998bdf3adac55da0f9e4614c72686b057d - remote: buf.build owner: grpc-ecosystem repository: grpc-gateway - commit: 11c9972ea0fd4c95a2c38d29bb1dc817 - digest: shake256:9c7ce822dff52ad28714465396fbe98e879409677a61687b7dd9bb3d1484aa5d1704c013698b24f34c5d51023dbff47287ecd9676271953c25e646b42ebb76c5 + commit: 3f42134f4c564983838425bc43c7a65f + digest: shake256:3d11d4c0fe5e05fda0131afefbce233940e27f0c31c5d4e385686aea58ccd30f72053f61af432fa83f1fc11cda57f5f18ca3da26a29064f73c5a0d076bba8d92 diff --git a/proto/defs/buf/validate/expression.proto b/proto/defs/buf/validate/expression.proto new file mode 100644 index 0000000..72ce36d --- /dev/null +++ b/proto/defs/buf/validate/expression.proto @@ -0,0 +1,92 @@ +// 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; + +option go_package = "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"; +option java_multiple_files = true; +option java_outer_classname = "ExpressionProto"; +option java_package = "build.buf.validate"; + +// `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. + 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. + 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. + string expression = 3; +} + +// `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_path` is a machine-readable identifier that points to the specific field that failed the 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. + string field_path = 1; + + // `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. + 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. + string message = 3; + + // `for_key` indicates whether the violation was caused by a map key, rather than a value. + bool for_key = 4; +} diff --git a/proto/defs/buf/validate/priv/private.proto b/proto/defs/buf/validate/priv/private.proto new file mode 100644 index 0000000..ddaf938 --- /dev/null +++ b/proto/defs/buf/validate/priv/private.proto @@ -0,0 +1,41 @@ +// 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.priv; + +import "google/protobuf/descriptor.proto"; + +option go_package = "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate/priv"; +option java_multiple_files = true; +option java_outer_classname = "PrivateProto"; +option java_package = "build.buf.validate.priv"; + +extend google.protobuf.FieldOptions { + // Do not use. Internal to protovalidate library + optional FieldConstraints field = 1160; +} + +// Do not use. Internal to protovalidate library +message FieldConstraints { + repeated Constraint cel = 1; +} + +// Do not use. Internal to protovalidate library +message Constraint { + string id = 1; + string message = 2; + string expression = 3; +} diff --git a/proto/defs/buf/validate/validate.proto b/proto/defs/buf/validate/validate.proto new file mode 100644 index 0000000..6d11ea6 --- /dev/null +++ b/proto/defs/buf/validate/validate.proto @@ -0,0 +1,3812 @@ +// 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; + +import "buf/validate/expression.proto"; +import "buf/validate/priv/private.proto"; +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; +} + +// 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; +} + +// FieldRules 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; + // `skipped` is an optional boolean attribute that specifies that the + // validation rules of this field should not be evaluated. If skipped is set to + // true, any validation rules set for the field will be ignored. + // + // ```proto + // message MyMessage { + // // The field `value` must not be set. + // optional MyOtherMessage value = 1 [(buf.validate.field).skipped = true]; + // } + // ``` + bool skipped = 24; + // If `required` is true, the field must be populated. Field presence can be + // described as "serialized in the wire format," which follows the following rules: + // + // - the following "nullable" fields must be explicitly set to be considered present: + // - singular message fields (may be their empty value) + // - member fields of a oneof (may be their default value) + // - proto3 optional fields (may be their default value) + // - proto2 scalar fields + // - proto3 scalar fields must be non-zero to be considered present + // - repeated and map fields must be non-empty to be considered present + // + // ```proto + // message MyMessage { + // // The field `value` must be set to a non-null value. + // optional MyOtherMessage value = 1 [(buf.validate.field).required = true]; + // } + // ``` + bool required = 25; + // If `ignore_empty` is true and applied to a non-nullable field (see + // `required` for more details), validation is skipped on the field if it is + // the default or empty value. Adding `ignore_empty` to a "nullable" field is + // a noop as these unset fields already skip validation (with the exception + // of `required`). + // + // ```proto + // message MyRepeated { + // // The field `value` min_len rule is only applied if the field isn't empty. + // repeated string value = 1 [ + // (buf.validate.field).ignore_empty = true, + // (buf.validate.field).min_len = 5 + // ]; + // } + // ``` + bool ignore_empty = 26; + 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; + } +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).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 [(priv.field).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. + bool finite = 8 [(priv.field).cel = { + id: "float.finite", + expression: "this.isNan() || this.isInf() ? 'value must be finite' : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).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 [(priv.field).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. + bool finite = 8 [(priv.field).cel = { + id: "double.finite", + expression: "this.isNan() || this.isInf() ? 'value must be finite' : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [ + (priv.field).cel = { + id: "int32.gt", + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "int32.not_in", + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [ + (priv.field).cel = { + id: "int64.gt", + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "int64.not_in", + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [ + (priv.field).cel = { + id: "uint32.gt", + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "uint32.not_in", + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [ + (priv.field).cel = { + id: "uint64.gt", + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "uint64.not_in", + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [ + (priv.field).cel = { + id: "sint32.gt", + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "sint32.not_in", + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [ + (priv.field).cel = { + id: "sint64.gt", + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "sint64.not_in", + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [ + (priv.field).cel = { + id: "fixed32.gt", + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "fixed32.not_in", + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [ + (priv.field).cel = { + id: "fixed64.gt", + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "fixed64.not_in", + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [ + (priv.field).cel = { + id: "sfixed32.gt", + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "sfixed32.not_in", + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [ + (priv.field).cel = { + id: "sfixed64.gt", + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "sfixed64.not_in", + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''", + }]; +} + +// 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 [(priv.field).cel = { + id: "bool.const", + expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "string.email", + message: "value must be a valid email address", + expression: "this.isEmail()" + }]; + + // `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 [(priv.field).cel = { + id: "string.hostname", + message: "value must be a valid hostname", + expression: "this.isHostname()", + }]; + + // `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 [(priv.field).cel = { + id: "string.ip", + message: "value must be a valid IP address", + expression: "this.isIp()", + }]; + + // `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 [(priv.field).cel = { + id: "string.ipv4", + message: "value must be a valid IPv4 address", + expression: "this.isIp(4)" + }]; + + // `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 [(priv.field).cel = { + id: "string.ipv6", + message: "value must be a valid IPv6 address", + expression: "this.isIp(6)", + }]; + + // `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 [(priv.field).cel = { + id: "string.uri", + message: "value must be a valid URI", + expression: "this.isUri()", + }]; + + // `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 [(priv.field).cel = { + id: "string.uri_ref", + message: "value must be a valid URI", + expression: "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 [(priv.field).cel = { + id: "string.address", + message: "value must be a valid hostname, or ip address", + expression: "this.isHostname() || this.isIp()", + }]; + + // `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 [(priv.field).cel = { + id: "string.uuid", + expression: "!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}$') ? 'value must be a valid UUID' : ''" + }]; + + // `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 [(priv.field).cel = { + id: "string.ip_with_prefixlen", + message: "value must be a valid IP prefix", + expression: "this.isIpPrefix()", + }]; + + // `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 lentgh + // string value = 1 [(buf.validate.field).string.ipv4_with_prefixlen = true]; + // } + // ``` + bool ipv4_with_prefixlen = 27 [(priv.field).cel = { + id: "string.ipv4_with_prefixlen", + message: "value must be a valid IPv4 address with prefix length", + expression: "this.isIpPrefix(4)" + }]; + + // `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 [(priv.field).cel = { + id: "string.ipv6_with_prefixlen", + message: "value must be a valid IPv6 address with prefix length", + expression: "this.isIpPrefix(6)", + }]; + + // `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 [(priv.field).cel = { + id: "string.ip_prefix", + message: "value must be a valid IP prefix", + expression: "this.isIpPrefix(true)", + }]; + + // `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 [(priv.field).cel = { + id: "string.ipv4_prefix", + message: "value must be a valid IPv4 prefix", + expression: "this.isIpPrefix(4, true)" + }]; + + // `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 [(priv.field).cel = { + id: "string.ipv6_prefix", + message: "value must be a valid IPv6 prefix", + expression: "this.isIpPrefix(6, true)", + }]; + + // `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 = 2]; + // } + // ``` + // + // #### 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 [ + (priv.field).cel = { + id: "string.well_known_regex.header_name" + expression: + "rules.well_known_regex == 1 && !this.matches(!has(rules.strict) || rules.strict ?" + "'^:?[0-9a-zA-Z!#$%&\\'*+-.^_|~\\x60]+$' :" + "'^[^\\u0000\\u000A\\u000D]+$') ? 'value must be a valid HTTP header name' : ''", + }, + (priv.field).cel = { + id: "string.well_known_regex.header_value", + expression: + "rules.well_known_regex == 2 && !this.matches(!has(rules.strict) || rules.strict ?" + "'^[^\\u0000-\\u0008\\u000A-\\u001F\\u007F]*$' :" + "'^[^\\u0000\\u000A\\u000D]*$') ? 'value must be a valid HTTP header value' : ''", + } + ]; + } + + // 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; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "bytes.ip", + expression: "this.size() != 4 && this.size() != 16 ? 'value must be a valid IP address' : ''" + }]; + + // `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 [(priv.field).cel = { + id: "bytes.ipv4", + expression: "this.size() != 4 ? 'value must be a valid IPv4 address' : ''" + }]; + + // `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 [(priv.field).cel = { + id: "bytes.ipv6", + expression: "this.size() != 16 ? 'value must be a valid IPv6 address' : ''" + }]; + } +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "enum.not_in", + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "repeated.unique" + message: "repeated value must contain unique items" + expression: "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; +} + +// 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 [(priv.field).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 [(priv.field).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; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [ + (priv.field).cel = { + id: "duration.gt", + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "duration.not_in", + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''", + }]; +} + +// 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 [(priv.field).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 [(priv.field).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 [(priv.field).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 [(priv.field).cel = { + id: "timestamp.lt_now", + expression: "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 [ + (priv.field).cel = { + id: "timestamp.gt", + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [ + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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]) : ''" + }, + (priv.field).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 [(priv.field).cel = { + id: "timestamp.gt_now", + expression: "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 [(priv.field).cel = { + id: "timestamp.within", + expression: "this < now-rules.within || this > now+rules.within ? 'value must be within %s of now'.format([rules.within]) : ''" + }]; +} diff --git a/proto/defs/cerbos/audit/v1/audit.proto b/proto/defs/cerbos/audit/v1/audit.proto index 8e64675..1927598 100644 --- a/proto/defs/cerbos/audit/v1/audit.proto +++ b/proto/defs/cerbos/audit/v1/audit.proto @@ -1,4 +1,4 @@ -// Copyright 2021-2023 Zenauth Ltd. +// Copyright 2021-2024 Zenauth Ltd. // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; @@ -6,6 +6,7 @@ syntax = "proto3"; package cerbos.audit.v1; import "cerbos/engine/v1/engine.proto"; +import "cerbos/policy/v1/policy.proto"; import "google/protobuf/timestamp.proto"; option csharp_namespace = "Cerbos.Api.V1.Audit"; @@ -48,6 +49,7 @@ message DecisionLogEntry { PlanResources plan_resources = 8; } map metadata = 15; + AuditTrail audit_trail = 16; } message MetaValues { @@ -60,3 +62,7 @@ message Peer { string user_agent = 3; string forwarded_for = 4; } + +message AuditTrail { + map effective_policies = 1; +} diff --git a/proto/defs/cerbos/effect/v1/effect.proto b/proto/defs/cerbos/effect/v1/effect.proto index 00fd3ce..97c37a8 100644 --- a/proto/defs/cerbos/effect/v1/effect.proto +++ b/proto/defs/cerbos/effect/v1/effect.proto @@ -1,4 +1,4 @@ -// Copyright 2021-2023 Zenauth Ltd. +// Copyright 2021-2024 Zenauth Ltd. // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; diff --git a/proto/defs/cerbos/engine/v1/engine.proto b/proto/defs/cerbos/engine/v1/engine.proto index 3acdaf2..022b818 100644 --- a/proto/defs/cerbos/engine/v1/engine.proto +++ b/proto/defs/cerbos/engine/v1/engine.proto @@ -1,17 +1,17 @@ -// Copyright 2021-2023 Zenauth Ltd. +// Copyright 2021-2024 Zenauth Ltd. // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; package cerbos.engine.v1; +import "buf/validate/validate.proto"; import "cerbos/effect/v1/effect.proto"; import "cerbos/schema/v1/schema.proto"; import "google/api/expr/v1alpha1/checked.proto"; import "google/api/field_behavior.proto"; import "google/protobuf/struct.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; -import "validate/validate.proto"; option csharp_namespace = "Cerbos.Api.V1.Engine"; option go_package = "github.com/cerbos/cerbos/api/genpb/cerbos/engine/v1;enginev1"; @@ -20,7 +20,8 @@ option java_package = "dev.cerbos.api.v1.engine"; message PlanResourcesInput { message Resource { string kind = 1 [ - (validate.rules).string = {min_len: 1}, + (buf.validate.field).string = {min_len: 1}, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Resource kind." @@ -28,13 +29,10 @@ message PlanResourcesInput { } ]; - map attr = 2 [ - (validate.rules).map.no_sparse = true, - (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Key-value pairs of contextual data about the resource that are known at a time of the request."} - ]; + map attr = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Key-value pairs of contextual data about the resource that are known at a time of the request."}]; string policy_version = 3 [ - (validate.rules).string.pattern = "^[[:word:]]*$", + (buf.validate.field).string = {pattern: "^[[:word:]]*$"}, (google.api.field_behavior) = OPTIONAL, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "The policy version to use to evaluate this request. If not specified, will default to the server-configured default version.", @@ -44,7 +42,7 @@ message PlanResourcesInput { ]; string scope = 4 [ - (validate.rules).string.pattern = "^([[:alnum:]][[:word:]\\-]*(\\.[[:word:]\\-]*)*)*$", + (buf.validate.field).string = {pattern: "^([[:alnum:]][[:word:]\\-]*(\\.[[:word:]\\-]*)*)*$"}, (google.api.field_behavior) = OPTIONAL, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "A dot-separated scope that describes the hierarchy this resource belongs to. This is used for determining policy inheritance." @@ -128,15 +126,15 @@ message PlanResourcesOutput { message CheckInput { string request_id = 1; Resource resource = 2 [ - (validate.rules).message.required = true, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED ]; Principal principal = 3 [ - (validate.rules).message.required = true, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED ]; repeated string actions = 4 [ - (validate.rules).repeated = { + (buf.validate.field).repeated = { unique: true, items { string {min_len: 1} @@ -175,7 +173,8 @@ message OutputEntry { message Resource { string kind = 1 [ - (validate.rules).string = {min_len: 1}, + (buf.validate.field).required = true, + (buf.validate.field).string = {min_len: 1}, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Name of the resource kind being accessed.", @@ -183,7 +182,7 @@ message Resource { } ]; string policy_version = 2 [ - (validate.rules).string.pattern = "^[[:word:]]*$", + (buf.validate.field).string = {pattern: "^[[:word:]]*$"}, (google.api.field_behavior) = OPTIONAL, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "The policy version to use to evaluate this request. If not specified, will default to the server-configured default version." @@ -192,7 +191,8 @@ message Resource { } ]; string id = 3 [ - (validate.rules).string = {min_len: 1}, + (buf.validate.field).required = true, + (buf.validate.field).string = {min_len: 1}, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "ID of the resource instance" @@ -200,14 +200,17 @@ message Resource { } ]; map attr = 4 [ - (validate.rules).map.no_sparse = true, + (buf.validate.field).map.keys = { + string: {min_len: 1} + }, + (buf.validate.field).map.values.required = true, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Kay-value pairs of contextual data about this resource that should be used during policy evaluation." example: "{\"owner\": \"bugs_bunny\"}" } ]; string scope = 5 [ - (validate.rules).string.pattern = "^([[:alnum:]][[:word:]\\-]*(\\.[[:word:]\\-]*)*)*$", + (buf.validate.field).string = {pattern: "^([[:alnum:]][[:word:]\\-]*(\\.[[:word:]\\-]*)*)*$"}, (google.api.field_behavior) = OPTIONAL, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "A dot-separated scope that describes the hierarchy this resource belongs to. This is used for determining policy inheritance." @@ -222,7 +225,8 @@ message Principal { json_schema: {description: "A person or application attempting to perform the actions on the set of resources."} }; string id = 1 [ - (validate.rules).string = {min_len: 1}, + (buf.validate.field).required = true, + (buf.validate.field).string = {min_len: 1}, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "ID of the principal" @@ -230,7 +234,7 @@ message Principal { } ]; string policy_version = 2 [ - (validate.rules).string.pattern = "^[[:word:]]*$", + (buf.validate.field).string = {pattern: "^[[:word:]]*$"}, (google.api.field_behavior) = OPTIONAL, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "The policy version to use to evaluate this request. If not specified, will default to the server-configured default version." @@ -239,13 +243,14 @@ message Principal { } ]; repeated string roles = 3 [ - (validate.rules).repeated = { + (buf.validate.field).repeated = { unique: true, min_items: 1, items { string {min_len: 1} } }, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Roles assigned to this principal from your identity management system." @@ -255,14 +260,17 @@ message Principal { } ]; map attr = 4 [ - (validate.rules).map.no_sparse = true, + (buf.validate.field).map.keys = { + string: {min_len: 1} + }, + (buf.validate.field).map.values.required = true, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Key-value pairs of contextual data about this principal that should be used during policy evaluation." example: "{\"beta_tester\": true}" } ]; string scope = 5 [ - (validate.rules).string.pattern = "^([[:alnum:]][[:word:]\\-]*(\\.[[:word:]\\-]*)*)*$", + (buf.validate.field).string = {pattern: "^([[:alnum:]][[:word:]\\-]*(\\.[[:word:]\\-]*)*)*$"}, (google.api.field_behavior) = OPTIONAL, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "A dot-separated scope that describes the hierarchy this principal belongs to. This is used for determining policy inheritance." diff --git a/proto/defs/cerbos/policy/v1/policy.proto b/proto/defs/cerbos/policy/v1/policy.proto index 0eac748..cd97f2f 100644 --- a/proto/defs/cerbos/policy/v1/policy.proto +++ b/proto/defs/cerbos/policy/v1/policy.proto @@ -1,28 +1,31 @@ -// Copyright 2021-2023 Zenauth Ltd. +// Copyright 2021-2024 Zenauth Ltd. // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; package cerbos.policy.v1; +import "buf/validate/validate.proto"; import "cerbos/effect/v1/effect.proto"; import "cerbos/engine/v1/engine.proto"; import "google/protobuf/struct.proto"; import "google/protobuf/timestamp.proto"; import "google/protobuf/wrappers.proto"; -import "validate/validate.proto"; option csharp_namespace = "Cerbos.Api.V1.Policy"; option go_package = "github.com/cerbos/cerbos/api/genpb/cerbos/policy/v1;policyv1"; option java_package = "dev.cerbos.api.v1.policy"; message Policy { - string api_version = 1 [(validate.rules).string.const = "api.cerbos.dev/v1"]; + string api_version = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string.const = "api.cerbos.dev/v1" + ]; bool disabled = 2; string description = 3; Metadata metadata = 4; oneof policy_type { - option (validate.required) = true; + option (buf.validate.oneof).required = true; ResourcePolicy resource_policy = 5; PrincipalPolicy principal_policy = 6; DerivedRoles derived_roles = 7; @@ -32,117 +35,167 @@ message Policy { string json_schema = 9 [json_name = "$schema"]; } +message SourceAttributes { + map attributes = 1; +} + message Metadata { string source_file = 1; map annotations = 2; google.protobuf.UInt64Value hash = 3; string store_identifer = 4 [deprecated = true]; string store_identifier = 5; + SourceAttributes source_attributes = 6; } message ResourcePolicy { - string resource = 1 [(validate.rules).string = {min_len: 1}]; - string version = 2 [(validate.rules).string.pattern = "^[[:word:]]+$"]; - repeated string import_derived_roles = 3 [(validate.rules).repeated = { + string resource = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string = {min_len: 1} + ]; + string version = 2 [ + (buf.validate.field).required = true, + (buf.validate.field).string = {pattern: "^[[:word:]]+$"} + ]; + repeated string import_derived_roles = 3 [(buf.validate.field).repeated = { unique: true, items { string {pattern: "^[[:word:]\\-\\.]+$"} } }]; repeated ResourceRule rules = 4; - string scope = 5 [(validate.rules).string.pattern = "^([[:alnum:]][[:word:]\\-]*(\\.[[:word:]\\-]*)*)*$"]; + string scope = 5 [(buf.validate.field).string.pattern = "^([[:alnum:]][[:word:]\\-]*(\\.[[:word:]\\-]*)*)*$"]; Schemas schemas = 6; Variables variables = 7; } message ResourceRule { - repeated string actions = 1 [(validate.rules).repeated = { - min_items: 1, - unique: true, - items { - string {min_len: 1} - } - }]; - repeated string derived_roles = 2 [(validate.rules).repeated = { + repeated string actions = 1 [ + (buf.validate.field).repeated = { + min_items: 1, + unique: true, + items { + string {min_len: 1} + } + }, + (buf.validate.field).required = true + ]; + repeated string derived_roles = 2 [(buf.validate.field).repeated = { unique: true, items { string {pattern: "^[[:word:]\\-\\.]+$"} } }]; - repeated string roles = 3 [(validate.rules).repeated = { + repeated string roles = 3 [(buf.validate.field).repeated = { unique: true, items { string {min_len: 1} } }]; Condition condition = 4; - cerbos.effect.v1.Effect effect = 5 [(validate.rules).enum = { - in: [ - 1, - 2 - ] - }]; - string name = 6 [(validate.rules).string.pattern = "^([[:alpha:]][[:word:]\\@\\.\\-]*)*$"]; + cerbos.effect.v1.Effect effect = 5 [ + (buf.validate.field).enum = { + in: [ + 1, + 2 + ] + }, + (buf.validate.field).required = true + ]; + string name = 6 [(buf.validate.field).string.pattern = "^([[:alpha:]][[:word:]\\@\\.\\-]*)*$"]; Output output = 7; } message PrincipalPolicy { - string principal = 1 [(validate.rules).string = {min_len: 1}]; - string version = 2 [(validate.rules).string.pattern = "^[[:word:]]+$"]; + string principal = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string = {min_len: 1} + ]; + string version = 2 [ + (buf.validate.field).required = true, + (buf.validate.field).string.pattern = "^[[:word:]]+$" + ]; repeated PrincipalRule rules = 3; - string scope = 4 [(validate.rules).string.pattern = "^([[:alnum:]][[:word:]\\-]*(\\.[[:word:]\\-]*)*)*$"]; + string scope = 4 [(buf.validate.field).string.pattern = "^([[:alnum:]][[:word:]\\-]*(\\.[[:word:]\\-]*)*)*$"]; Variables variables = 5; } message PrincipalRule { message Action { - string action = 1 [(validate.rules).string.min_len = 1]; + string action = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string = {min_len: 1} + ]; Condition condition = 2; - cerbos.effect.v1.Effect effect = 3 [(validate.rules).enum = { - in: [ - 1, - 2 - ] - }]; - string name = 4 [(validate.rules).string.pattern = "^([[:alpha:]][[:word:]\\@\\.\\-]*)*$"]; + cerbos.effect.v1.Effect effect = 3 [ + (buf.validate.field).enum = { + in: [ + 1, + 2 + ] + }, + (buf.validate.field).required = true + ]; + string name = 4 [(buf.validate.field).string.pattern = "^([[:alpha:]][[:word:]\\@\\.\\-]*)*$"]; Output output = 5; } - string resource = 1 [(validate.rules).string = {min_len: 1}]; - repeated Action actions = 2 [(validate.rules).repeated.min_items = 1]; + string resource = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string = {min_len: 1} + ]; + repeated Action actions = 2 [ + (buf.validate.field).required = true, + (buf.validate.field).repeated.min_items = 1 + ]; } message DerivedRoles { - string name = 1 [(validate.rules).string = { - pattern: "^[[:word:]\\-\\.]+$", - min_len: 1 - }]; - repeated RoleDef definitions = 2 [(validate.rules).repeated.min_items = 1]; + string name = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string = { + pattern: "^[[:word:]\\-\\.]+$", + min_len: 1 + } + ]; + repeated RoleDef definitions = 2 [ + (buf.validate.field).repeated.min_items = 1, + (buf.validate.field).required = true + ]; Variables variables = 3; } message RoleDef { - string name = 1 [(validate.rules).string.pattern = "^[[:word:]\\-\\.]+$"]; - repeated string parent_roles = 2 [(validate.rules).repeated = { - unique: true, - min_items: 1, - items { - string {min_len: 1} - } - }]; + string name = 1 [ + (buf.validate.field).string.pattern = "^[[:word:]\\-\\.]+$", + (buf.validate.field).required = true + ]; + repeated string parent_roles = 2 [ + (buf.validate.field).repeated = { + unique: true, + min_items: 1, + items { + string {min_len: 1} + } + }, + (buf.validate.field).required = true + ]; Condition condition = 3; } message ExportVariables { - string name = 1 [(validate.rules).string = { - pattern: "^[[:word:]\\-\\.]+$", - min_len: 1 - }]; + string name = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string = { + pattern: "^[[:word:]\\-\\.]+$", + min_len: 1 + } + ]; map definitions = 2; } message Variables { - repeated string import = 1 [(validate.rules).repeated = { + repeated string import = 1 [(buf.validate.field).repeated = { unique: true, items { string {pattern: "^[[:word:]\\-\\.]+$"} @@ -153,7 +206,7 @@ message Variables { message Condition { oneof condition { - option (validate.required) = true; + option (buf.validate.oneof).required = true; Match match = 1; string script = 2; } @@ -161,11 +214,14 @@ message Condition { message Match { message ExprList { - repeated Match of = 1 [(validate.rules).repeated = {min_items: 1}]; + repeated Match of = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).repeated = {min_items: 1} + ]; } oneof op { - option (validate.required) = true; + option (buf.validate.oneof).required = true; ExprList all = 1; ExprList any = 2; ExprList none = 3; @@ -174,22 +230,34 @@ message Match { } message Output { - string expr = 1; + message When { + string rule_activated = 1; + string condition_not_met = 2; + } + + string expr = 1 [deprecated = true]; + When when = 2; } message Schemas { message IgnoreWhen { - repeated string actions = 1 [(validate.rules).repeated = { - unique: true, - min_items: 1, - items { - string {min_len: 1} - } - }]; + repeated string actions = 1 [ + (buf.validate.field).repeated = { + unique: true, + min_items: 1, + items { + string {min_len: 1} + } + }, + (buf.validate.field).required = true + ]; } message Schema { - string ref = 1 [(validate.rules).string = {min_len: 1}]; + string ref = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string = {min_len: 1} + ]; IgnoreWhen ignore_when = 2; } @@ -216,14 +284,22 @@ message TestFixture { message TestOptions { google.protobuf.Timestamp now = 1; + bool lenient_scope_search = 2; + map globals = 3; } message TestSuite { - string name = 1 [(validate.rules).string.min_len = 1]; + string name = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string.min_len = 1 + ]; string description = 2; bool skip = 3; string skip_reason = 4; - repeated TestTable tests = 5 [(validate.rules).repeated.min_items = 1]; + repeated TestTable tests = 5 [ + (buf.validate.field).repeated.min_items = 1, + (buf.validate.field).required = true + ]; map principals = 6; map resources = 7; map aux_data = 8; @@ -233,78 +309,136 @@ message TestSuite { message TestTable { message Input { - repeated string principals = 1 [(validate.rules).repeated = { - min_items: 1, - unique: true, - items: { - string: {min_len: 1} - } - }]; - repeated string resources = 2 [(validate.rules).repeated = { - min_items: 1, - unique: true, - items: { - string: {min_len: 1} - } - }]; - repeated string actions = 3 [(validate.rules).repeated = { - min_items: 1, - unique: true, - items: { - string: {min_len: 1} - } - }]; + repeated string principals = 1 [ + (buf.validate.field).repeated = { + min_items: 1, + unique: true, + items: { + string: {min_len: 1} + } + }, + (buf.validate.field).required = true + ]; + repeated string resources = 2 [ + (buf.validate.field).repeated = { + min_items: 1, + unique: true, + items: { + string: {min_len: 1} + } + }, + (buf.validate.field).required = true + ]; + repeated string actions = 3 [ + (buf.validate.field).repeated = { + min_items: 1, + unique: true, + items: { + string: {min_len: 1} + } + }, + (buf.validate.field).required = true + ]; string aux_data = 4; } message OutputExpectations { - string action = 1 [(validate.rules).string.min_len = 1]; - repeated cerbos.engine.v1.OutputEntry expected = 2 [(validate.rules).repeated.min_items = 1]; + string action = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string.min_len = 1 + ]; + repeated cerbos.engine.v1.OutputEntry expected = 2 [ + (buf.validate.field).repeated.min_items = 1, + (buf.validate.field).required = true + ]; } message Expectation { - string principal = 1 [(validate.rules).string.min_len = 1]; - string resource = 2 [(validate.rules).string.min_len = 1]; - map actions = 3 [(validate.rules).map = { - min_pairs: 1, - keys: { - string: {min_len: 1} - } - }]; + string principal = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string.min_len = 1 + ]; + string resource = 2 [ + (buf.validate.field).required = true, + (buf.validate.field).string.min_len = 1 + ]; + map actions = 3 [ + (buf.validate.field).map = { + min_pairs: 1, + keys: { + string: {min_len: 1} + }, + values: { + enum: { + in: [ + 1, + 2 + ] + } + } + }, + (buf.validate.field).required = true + ]; repeated OutputExpectations outputs = 4; } - string name = 1 [(validate.rules).string.min_len = 1]; + string name = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string.min_len = 1 + ]; string description = 2; bool skip = 3; string skip_reason = 4; - Input input = 5 [(validate.rules).message.required = true]; - repeated Expectation expected = 6 [(validate.rules).repeated.min_items = 1]; + Input input = 5 [(buf.validate.field).required = true]; + repeated Expectation expected = 6 [ + (buf.validate.field).repeated.min_items = 1, + (buf.validate.field).required = true + ]; TestOptions options = 7; } message Test { message TestName { - string test_table_name = 1 [(validate.rules).string.min_len = 1]; - string principal_key = 2 [(validate.rules).string.min_len = 1]; - string resource_key = 3 [(validate.rules).string.min_len = 1]; + string test_table_name = 1 [ + (buf.validate.field).required = true, + (buf.validate.field).string.min_len = 1 + ]; + string principal_key = 2 [ + (buf.validate.field).required = true, + (buf.validate.field).string.min_len = 1 + ]; + string resource_key = 3 [ + (buf.validate.field).required = true, + (buf.validate.field).string.min_len = 1 + ]; } message OutputEntries { map entries = 1; } - TestName name = 1 [(validate.rules).message.required = true]; + TestName name = 1 [(buf.validate.field).required = true]; string description = 2; bool skip = 3; string skip_reason = 4; - cerbos.engine.v1.CheckInput input = 5 [(validate.rules).message.required = true]; - map expected = 6 [(validate.rules).map = { - min_pairs: 1, - keys: { - string: {min_len: 1} - } - }]; + cerbos.engine.v1.CheckInput input = 5 [(buf.validate.field).required = true]; + map expected = 6 [ + (buf.validate.field).map = { + min_pairs: 1, + keys: { + string: {min_len: 1} + }, + values: { + enum: { + in: [ + 1, + 2 + ] + } + } + }, + (buf.validate.field).required = true + ]; TestOptions options = 7; map expected_outputs = 8; } @@ -364,6 +498,7 @@ message TestResults { oneof outcome { Failure failure = 2; string error = 3; + Success success = 5; } repeated cerbos.engine.v1.Trace engine_trace = 4; } @@ -391,6 +526,11 @@ message TestResults { repeated OutputFailure outputs = 3; } + message Success { + cerbos.effect.v1.Effect effect = 1; + repeated cerbos.engine.v1.OutputEntry outputs = 2; + } + repeated Suite suites = 1; Summary summary = 2; } diff --git a/proto/defs/cerbos/request/v1/request.proto b/proto/defs/cerbos/request/v1/request.proto index a627ef9..d8f3d80 100644 --- a/proto/defs/cerbos/request/v1/request.proto +++ b/proto/defs/cerbos/request/v1/request.proto @@ -1,10 +1,11 @@ -// Copyright 2021-2023 Zenauth Ltd. +// Copyright 2021-2024 Zenauth Ltd. // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; package cerbos.request.v1; +import "buf/validate/validate.proto"; import "cerbos/engine/v1/engine.proto"; import "cerbos/policy/v1/policy.proto"; import "cerbos/schema/v1/schema.proto"; @@ -13,7 +14,6 @@ import "google/protobuf/duration.proto"; import "google/protobuf/struct.proto"; import "google/protobuf/timestamp.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; -import "validate/validate.proto"; option csharp_namespace = "Cerbos.Api.V1.Request"; option go_package = "github.com/cerbos/cerbos/api/genpb/cerbos/request/v1;requestv1"; @@ -30,7 +30,8 @@ message PlanResourcesRequest { }]; string action = 2 [ - (validate.rules).string.min_len = 1, + (buf.validate.field).required = true, + (buf.validate.field).string.min_len = 1, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Action to be applied to each resource in the list." @@ -39,12 +40,12 @@ message PlanResourcesRequest { ]; cerbos.engine.v1.Principal principal = 3 [ - (validate.rules).message.required = true, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED ]; cerbos.engine.v1.PlanResourcesInput.Resource resource = 4 [ - (validate.rules).message.required = true, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED ]; @@ -64,13 +65,14 @@ message CheckResourceSetRequest { example: "\"c2db17b8-4f9f-4fb1-acfd-9162a02be42b\"" }]; repeated string actions = 2 [ - (validate.rules).repeated = { + (buf.validate.field).repeated = { unique: true, min_items: 1, items { string {min_len: 1} } }, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "List of actions being performed on the set of resources." @@ -80,11 +82,11 @@ message CheckResourceSetRequest { } ]; cerbos.engine.v1.Principal principal = 3 [ - (validate.rules).message.required = true, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED ]; ResourceSet resource = 4 [ - (validate.rules).message.required = true, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED ]; bool include_meta = 5 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Opt to receive request processing metadata in the response."}]; @@ -97,7 +99,8 @@ message ResourceSet { }; string kind = 1 [ - (validate.rules).string = {min_len: 1}, + (buf.validate.field).required = true, + (buf.validate.field).string = {min_len: 1}, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Resource kind." @@ -105,7 +108,7 @@ message ResourceSet { } ]; string policy_version = 2 [ - (validate.rules).string.pattern = "^[[:word:]]*$", + (buf.validate.field).string.pattern = "^[[:word:]]*$", (google.api.field_behavior) = OPTIONAL, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "The policy version to use to evaluate this request. If not specified, will default to the server-configured default version.", @@ -114,10 +117,8 @@ message ResourceSet { } ]; map instances = 3 [ - (validate.rules).map = { - min_pairs: 1, - no_sparse: true - }, + (buf.validate.field).map = {min_pairs: 1}, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Set of resource instances to check. Each instance must be keyed by an application-specific unique identifier.", @@ -126,7 +127,7 @@ message ResourceSet { } ]; string scope = 4 [ - (validate.rules).string.pattern = "^([[:alnum:]][[:word:]\\-]*(\\.[[:word:]\\-]*)*)*$", + (buf.validate.field).string.pattern = "^([[:alnum:]][[:word:]\\-]*(\\.[[:word:]\\-]*)*)*$", (google.api.field_behavior) = OPTIONAL, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "A dot-separated scope that describes the hierarchy these resources belong to. This is used for determining policy inheritance." @@ -140,10 +141,7 @@ message AttributesMap { json_schema: {description: "Unique identifier for the resource instance."} }; - map attr = 1 [ - (validate.rules).map.no_sparse = true, - (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Key-value pairs of contextual data about this instance that should be used during policy evaluation."} - ]; + map attr = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Key-value pairs of contextual data about this instance that should be used during policy evaluation."}]; } // Deprecated. See CheckResourcesRequest. @@ -154,13 +152,14 @@ message CheckResourceBatchRequest { message BatchEntry { repeated string actions = 1 [ - (validate.rules).repeated = { + (buf.validate.field).repeated = { unique: true, min_items: 1, items { string {min_len: 1} } }, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "List of actions being performed on the resource." @@ -170,7 +169,7 @@ message CheckResourceBatchRequest { } ]; cerbos.engine.v1.Resource resource = 2 [ - (validate.rules).message.required = true, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED ]; } @@ -180,11 +179,12 @@ message CheckResourceBatchRequest { example: "\"c2db17b8-4f9f-4fb1-acfd-9162a02be42b\"" }]; cerbos.engine.v1.Principal principal = 2 [ - (validate.rules).message.required = true, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED ]; repeated BatchEntry resources = 3 [ - (validate.rules).repeated = {min_items: 1}, + (buf.validate.field).repeated = {min_items: 1}, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "List of resources and actions." @@ -204,13 +204,14 @@ message CheckResourcesRequest { message ResourceEntry { repeated string actions = 1 [ - (validate.rules).repeated = { + (buf.validate.field).repeated = { unique: true, min_items: 1, items { string {min_len: 1} } }, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "List of actions being performed on the resource." @@ -220,7 +221,7 @@ message CheckResourcesRequest { } ]; cerbos.engine.v1.Resource resource = 2 [ - (validate.rules).message.required = true, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED ]; } @@ -231,11 +232,12 @@ message CheckResourcesRequest { }]; bool include_meta = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Add request processing metadata to the response."}]; cerbos.engine.v1.Principal principal = 3 [ - (validate.rules).message.required = true, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED ]; repeated ResourceEntry resources = 4 [ - (validate.rules).repeated = {min_items: 1}, + (buf.validate.field).repeated = {min_items: 1}, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "List of resources and actions." @@ -258,7 +260,8 @@ message AuxData { }; string token = 1 [ - (validate.rules).string = {min_len: 1}, + (buf.validate.field).required = true, + (buf.validate.field).string = {min_len: 1}, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "JWT from the original request" @@ -292,15 +295,17 @@ message AuxData { message File { string file_name = 1 [ - (validate.rules).string.min_len = 1, + (buf.validate.field).required = true, + (buf.validate.field).string.min_len = 1, (google.api.field_behavior) = REQUIRED ]; bytes contents = 2 [ - (validate.rules).bytes = { + (buf.validate.field).bytes = { min_len: 1, max_len: 1048576 }, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED ]; } @@ -313,10 +318,11 @@ message PlaygroundValidateRequest { string playground_id = 1; repeated File files = 2 [ - (validate.rules).repeated = { + (buf.validate.field).repeated = { min_items: 1, max_items: 30 }, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "List of files." @@ -334,10 +340,11 @@ message PlaygroundTestRequest { string playground_id = 1; repeated File files = 2 [ - (validate.rules).repeated = { + (buf.validate.field).repeated = { min_items: 1, max_items: 30 }, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "List of files." @@ -355,10 +362,11 @@ message PlaygroundEvaluateRequest { string playground_id = 1; repeated File files = 2 [ - (validate.rules).repeated = { + (buf.validate.field).repeated = { min_items: 1, max_items: 30 }, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "List of files." @@ -368,17 +376,17 @@ message PlaygroundEvaluateRequest { ]; cerbos.engine.v1.Principal principal = 3 [ - (validate.rules).message.required = true, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED ]; cerbos.engine.v1.Resource resource = 4 [ - (validate.rules).message.required = true, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED ]; repeated string actions = 5 [ - (validate.rules).repeated = { + (buf.validate.field).repeated = { unique: true, min_items: 1, max_items: 50, @@ -386,6 +394,7 @@ message PlaygroundEvaluateRequest { string {min_len: 1} } }, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "List of actions being performed on the resource." @@ -406,10 +415,11 @@ message PlaygroundProxyRequest { string playground_id = 1; repeated File files = 2 [ - (validate.rules).repeated = { + (buf.validate.field).repeated = { min_items: 1, max_items: 30 }, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "List of files." @@ -419,7 +429,7 @@ message PlaygroundProxyRequest { ]; oneof proxy_request { - option (validate.required) = true; + option (buf.validate.oneof).required = true; CheckResourceSetRequest check_resource_set = 3; CheckResourceBatchRequest check_resource_batch = 4; PlanResourcesRequest plan_resources = 5; @@ -433,10 +443,11 @@ message AddOrUpdatePolicyRequest { }; repeated cerbos.policy.v1.Policy policies = 1 [ - (validate.rules).repeated = { + (buf.validate.field).repeated = { min_items: 1, max_items: 10 }, + (buf.validate.field).required = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "List of policies." @@ -459,10 +470,8 @@ message ListAuditLogEntriesRequest { }; google.protobuf.Timestamp start = 1 [ - (validate.rules).timestamp = { - required: true, - lt_now: true, - }, + (buf.validate.field).required = true, + (buf.validate.field).timestamp.lt_now = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Start date in ISO 8601 format." @@ -470,10 +479,8 @@ message ListAuditLogEntriesRequest { } ]; google.protobuf.Timestamp end = 2 [ - (validate.rules).timestamp = { - required: true, - lt_now: true, - }, + (buf.validate.field).required = true, + (buf.validate.field).timestamp.lt_now = true, (google.api.field_behavior) = REQUIRED, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "End date in ISO 8601 format." @@ -483,12 +490,13 @@ message ListAuditLogEntriesRequest { } Kind kind = 1 [ - (validate.rules).enum = { + (buf.validate.field).enum = { in: [ 1, 2 ] }, + (buf.validate.field).required = true, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Kind of log entry" enum: [ @@ -498,9 +506,10 @@ message ListAuditLogEntriesRequest { } ]; oneof filter { - option (validate.required) = true; + option (buf.validate.oneof).required = true; uint32 tail = 2 [ - (validate.rules).uint32.lte = 1000, + (buf.validate.field).uint32.gte = 1, + (buf.validate.field).uint32.lte = 1000, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Last N entries." minimum: 1 @@ -510,7 +519,7 @@ message ListAuditLogEntriesRequest { TimeRange between = 3; google.protobuf.Duration since = 4 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Entries since N hours/minutes ago"}]; string lookup = 5 [ - (validate.rules).string = {pattern: "^[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}$"}, + (buf.validate.field).string = {pattern: "^[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}$"}, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "By Call ID" pattern: "^[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}$" @@ -553,7 +562,7 @@ message GetPolicyRequest { }; repeated string id = 1 [ (google.api.field_behavior) = REQUIRED, - (validate.rules).repeated = { + (buf.validate.field).repeated = { unique: true, min_items: 1, max_items: 25, @@ -564,6 +573,7 @@ message GetPolicyRequest { } } }, + (buf.validate.field).required = true, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "For blob, disk, git stores use file name (.yaml). For mysql, postgres, sqlite3 use id (..) of the policy" example: "\"principal.sarah.vdefault\"" @@ -577,7 +587,7 @@ message DisablePolicyRequest { }; repeated string id = 1 [ (google.api.field_behavior) = REQUIRED, - (validate.rules).repeated = { + (buf.validate.field).repeated = { unique: true, min_items: 1, max_items: 25, @@ -588,6 +598,7 @@ message DisablePolicyRequest { } } }, + (buf.validate.field).required = true, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Unique identifier for the policy" example: "\"principal.sarah.vdefault\"" @@ -601,7 +612,7 @@ message EnablePolicyRequest { }; repeated string id = 1 [ (google.api.field_behavior) = REQUIRED, - (validate.rules).repeated = { + (buf.validate.field).repeated = { unique: true, min_items: 1, max_items: 25, @@ -612,6 +623,7 @@ message EnablePolicyRequest { } } }, + (buf.validate.field).required = true, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Unique identifier for the policy" example: "\"principal.sarah.vdefault\"" @@ -619,6 +631,28 @@ message EnablePolicyRequest { ]; } +message InspectPoliciesRequest { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: {description: "Inspect policies request"} + }; + bool include_disabled = 1 [ + (google.api.field_behavior) = OPTIONAL, + (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Include disabled policies"} + ]; + string name_regexp = 2 [ + (google.api.field_behavior) = OPTIONAL, + (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Filter policies by name with regexp"} + ]; + string scope_regexp = 3 [ + (google.api.field_behavior) = OPTIONAL, + (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Filter policies by scope with regexp"} + ]; + string version_regexp = 4 [ + (google.api.field_behavior) = OPTIONAL, + (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Filter policies by version with regexp"} + ]; +} + message AddOrUpdateSchemaRequest { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { json_schema: {description: "Add/update schema request"} @@ -626,10 +660,11 @@ message AddOrUpdateSchemaRequest { repeated cerbos.schema.v1.Schema schemas = 1 [ (google.api.field_behavior) = REQUIRED, - (validate.rules).repeated = { + (buf.validate.field).repeated = { min_items: 1, max_items: 10 }, + (buf.validate.field).required = true, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "List of schemas." min_items: 1 @@ -650,7 +685,7 @@ message GetSchemaRequest { }; repeated string id = 1 [ (google.api.field_behavior) = REQUIRED, - (validate.rules).repeated = { + (buf.validate.field).repeated = { unique: true, min_items: 1, max_items: 25, @@ -661,6 +696,7 @@ message GetSchemaRequest { } } }, + (buf.validate.field).required = true, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Unique identifier for the schema" example: "\"principal.json\"" @@ -674,7 +710,7 @@ message DeleteSchemaRequest { }; repeated string id = 1 [ (google.api.field_behavior) = REQUIRED, - (validate.rules).repeated = { + (buf.validate.field).repeated = { unique: true, min_items: 1, max_items: 25, @@ -685,6 +721,7 @@ message DeleteSchemaRequest { } } }, + (buf.validate.field).required = true, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Unique identifier for the schema" example: "\"principal.json\"" diff --git a/proto/defs/cerbos/response/v1/response.proto b/proto/defs/cerbos/response/v1/response.proto index 918f2e2..c4ef9cb 100644 --- a/proto/defs/cerbos/response/v1/response.proto +++ b/proto/defs/cerbos/response/v1/response.proto @@ -1,4 +1,4 @@ -// Copyright 2021-2023 Zenauth Ltd. +// Copyright 2021-2024 Zenauth Ltd. // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; @@ -60,6 +60,8 @@ message PlanResourcesResponse { Meta meta = 6 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Optional metadata about the request evaluation process"}]; repeated cerbos.schema.v1.ValidationError validation_errors = 7 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "List of validation errors (if schema validation is enabled)"}]; + + string cerbos_call_id = 8 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Audit log call ID associated with this request"}]; } // Deprecated. See CheckResourcesResponse. @@ -70,7 +72,10 @@ message CheckResourceSetResponse { message ActionEffectMap { map actions = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Mapping of each action to an effect."}]; - repeated cerbos.schema.v1.ValidationError validation_errors = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "List of validation errors (if schema validation is enabled)"}]; + repeated cerbos.schema.v1.ValidationError validation_errors = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: + "List of validation errors (if schema validation is " + "enabled)" +}]; } message Meta { @@ -97,18 +102,32 @@ message CheckResourceSetResponse { json_schema: {description: "Unique resource instance ID supplied in the request."} }; map actions = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { - description: "Metadata about the effect calculated for each action on this resource instance." - example: "{\"view:*\":{\"matched_policy\": \"album:object:default\"},\"comment\":{\"matched_policy\": \"album:object:default\"}}" + description: + "Metadata about the effect calculated for each " + "action on this resource instance." + example: + "{\"view:*\":{\"matched_policy\": " + "\"album:object:default\"},\"comment\":{\"matched_" + "policy\": \"album:object:default\"}}" }]; repeated string effective_derived_roles = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { - description: "Derived roles that were effective during policy evaluation." + description: + "Derived roles that were effective during policy " + "evaluation." example: "[\"owner\"]" }]; } map resource_instances = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Metadata about resource instances." - example: "{\"XX125\": {\"actions\": {\"view:*\":{\"matched_policy\": \"album:object:default\"},\"comment\":{\"matched_policy\": \"album:object:default\"}}, \"effective_derived_roles\": [\"owner\"]}, \"XX225\": {\"actions\": {\"view:*\":{\"matched_policy\": \"album:object:default\"},\"comment\":{\"matched_policy\": \"album:object:default\"}}}}" + example: + "{\"XX125\": {\"actions\": {\"view:*\":{\"matched_policy\": " + "\"album:object:default\"},\"comment\":{\"matched_policy\": " + "\"album:object:default\"}}, \"effective_derived_roles\": " + "[\"owner\"]}, \"XX225\": {\"actions\": " + "{\"view:*\":{\"matched_policy\": " + "\"album:object:default\"},\"comment\":{\"matched_policy\": " + "\"album:object:default\"}}}}" }]; } @@ -117,8 +136,14 @@ message CheckResourceSetResponse { example: "\"c2db17b8-4f9f-4fb1-acfd-9162a02be42b\"" }]; map resource_instances = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { - description: "Results for each resource instance, keyed by the ID supplied in the request" - example: "{\"XX125\":{\"actions\":{\"view:*\":\"EFFECT_ALLOW\", \"comment\": \"EFFECT_ALLOW\"}}, \"XX225\":{\"actions\":{\"view:*\":\"EFFECT_DENY\", \"comment\": \"EFFECT_DENY\"}}}" + description: + "Results for each resource instance, keyed by the ID " + "supplied in the request" + example: + "{\"XX125\":{\"actions\":{\"view:*\":\"EFFECT_ALLOW\", " + "\"comment\": \"EFFECT_ALLOW\"}}, " + "\"XX225\":{\"actions\":{\"view:*\":\"EFFECT_DENY\", " + "\"comment\": \"EFFECT_DENY\"}}}" }]; Meta meta = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Optional metadata about the request evaluation process"}]; } @@ -138,7 +163,10 @@ message CheckResourceBatchResponse { description: "Mapping of each action to an effect." example: "{\"view\":\"EFFECT_ALLOW\"}" }]; - repeated cerbos.schema.v1.ValidationError validation_errors = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "List of validation errors (if schema validation is enabled)"}]; + repeated cerbos.schema.v1.ValidationError validation_errors = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: + "List of validation errors (if schema validation is " + "enabled)" +}]; } string request_id = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { @@ -147,7 +175,9 @@ message CheckResourceBatchResponse { }]; repeated ActionEffectMap results = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Result for each resource" - example: "[{\"resourceId\":\"XX125\",\"actions\":{\"view\":\"EFFECT_ALLOW\"}}]" + example: + "[{\"resourceId\":\"XX125\",\"actions\":{\"view\":\"EFFECT_" + "ALLOW\"}}]" }]; } @@ -167,12 +197,18 @@ message CheckResourcesResponse { example: "\"album:photo\"", }]; string policy_version = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { - description: "The policy version to use to evaluate this request. If not specified, will default to the server-configured default version." + description: + "The policy version to use to evaluate this request. " + "If not specified, will default to the " + "server-configured default version." pattern: "^[[:word:]]*$" example: "\"default\"" }]; string scope = 4 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { - description: "A dot-separated scope that describes the hierarchy this resource belongs to. This is used for determining policy inheritance." + description: + "A dot-separated scope that describes the hierarchy " + "this resource belongs to. This is used for " + "determining policy inheritance." pattern: "^([[:alnum:]][[:word:]\\-]*(\\.[[:word:]\\-]*)*)*$" example: "\"acme.corp\"" }]; @@ -198,11 +234,18 @@ message CheckResourcesResponse { } map actions = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { - description: "Metadata about the effect calculated for each action on this resource instance." - example: "{\"view:*\":{\"matched_policy\": \"album:object:default\"},\"comment\":{\"matched_policy\": \"album:object:default\"}}" + description: + "Metadata about the effect calculated for each " + "action on this resource instance." + example: + "{\"view:*\":{\"matched_policy\": " + "\"album:object:default\"},\"comment\":{\"matched_" + "policy\": \"album:object:default\"}}" }]; repeated string effective_derived_roles = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { - description: "Derived roles that were effective during policy evaluation." + description: + "Derived roles that were effective during policy " + "evaluation." example: "[\"owner\"]" }]; } @@ -212,14 +255,24 @@ message CheckResourcesResponse { description: "Mapping of each action to an effect." example: "{\"view\":\"EFFECT_ALLOW\"}" }]; - repeated cerbos.schema.v1.ValidationError validation_errors = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "List of validation errors (if schema validation is enabled)"}]; + repeated cerbos.schema.v1.ValidationError validation_errors = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: + "List of validation errors (if schema validation is " + "enabled)" +}]; Meta meta = 4 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Metadata about policy evaluation" - example: "{\"actions\": {\"view:*\":{\"matched_policy\": \"album:object:default\"},\"comment\":{\"matched_policy\": \"album:object:default\"}}, \"effective_derived_roles\": [\"owner\"]}" + example: + "{\"actions\": {\"view:*\":{\"matched_policy\": " + "\"album:object:default\"},\"comment\":{\"matched_policy\":" + " \"album:object:default\"}}, \"effective_derived_roles\": " + "[\"owner\"]}" }]; repeated cerbos.engine.v1.OutputEntry outputs = 5 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Output for each rule with outputs configured" - example: "[{\"src\": \"resource.expense.v1/acme#rule-001\", \"val\": \"view_allowed:alice\"}, {\"src\": \"resource.expense.v1/acme#rule-002\", \"val\": \"foo\"}]" + example: + "[{\"src\": \"resource.expense.v1/acme#rule-001\", " + "\"val\": \"view_allowed:alice\"}, {\"src\": " + "\"resource.expense.v1/acme#rule-002\", \"val\": \"foo\"}]" }]; } @@ -229,8 +282,12 @@ message CheckResourcesResponse { }]; repeated ResultEntry results = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Result for each resource" - example: "[{\"resource\": {\"Id\":\"XX125\", \"kind\":\"album:object\"}, \"actions\":{\"view\":\"EFFECT_ALLOW\",\"comment\":\"EFFECT_DENY\"}}]" + example: + "[{\"resource\": {\"Id\":\"XX125\", \"kind\":\"album:object\"}, " + "\"actions\":{\"view\":\"EFFECT_ALLOW\",\"comment\":\"EFFECT_" + "DENY\"}}]" }]; + string cerbos_call_id = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "Audit log call ID associated with this request"}]; } message PlaygroundFailure { @@ -238,9 +295,16 @@ message PlaygroundFailure { json_schema: {description: "Playground response"} }; + message ErrorDetails { + uint32 line = 1; + uint32 column = 2; + string context = 3; + } + message Error { string file = 1; string error = 2; + ErrorDetails details = 3; } repeated Error errors = 1; @@ -376,6 +440,17 @@ message EnablePolicyResponse { uint32 enabled_policies = 1; } +message InspectPoliciesResponse { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: {description: "Inspect policies response"} + }; + message Result { + repeated string actions = 1; + } + + map results = 1; +} + message AddOrUpdateSchemaResponse { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { json_schema: {description: "Add/update schema response"} diff --git a/proto/defs/cerbos/schema/v1/schema.proto b/proto/defs/cerbos/schema/v1/schema.proto index e19a7a1..853a002 100644 --- a/proto/defs/cerbos/schema/v1/schema.proto +++ b/proto/defs/cerbos/schema/v1/schema.proto @@ -1,13 +1,13 @@ -// Copyright 2021-2023 Zenauth Ltd. +// Copyright 2021-2024 Zenauth Ltd. // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; package cerbos.schema.v1; +import "buf/validate/validate.proto"; import "google/api/field_behavior.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; -import "validate/validate.proto"; option csharp_namespace = "Cerbos.Api.V1.Schema"; option go_package = "github.com/cerbos/cerbos/api/genpb/cerbos/schema/v1;schemav1"; @@ -28,7 +28,8 @@ message ValidationError { message Schema { string id = 1 [ (google.api.field_behavior) = REQUIRED, - (validate.rules).string = { + (buf.validate.field).required = true, + (buf.validate.field).string = { min_len: 1, max_len: 255 }, @@ -39,7 +40,8 @@ message Schema { ]; bytes definition = 2 [ (google.api.field_behavior) = REQUIRED, - (validate.rules).bytes = {min_len: 10}, + (buf.validate.field).bytes = {min_len: 10}, + (buf.validate.field).required = true, (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "JSON schema definition" example: "{\"type\":\"object\", \"properties\":{}}" diff --git a/proto/defs/cerbos/svc/v1/svc.proto b/proto/defs/cerbos/svc/v1/svc.proto index 918f478..f416442 100644 --- a/proto/defs/cerbos/svc/v1/svc.proto +++ b/proto/defs/cerbos/svc/v1/svc.proto @@ -1,4 +1,4 @@ -// Copyright 2021-2023 Zenauth Ltd. +// Copyright 2021-2024 Zenauth Ltd. // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; @@ -116,6 +116,19 @@ service CerbosAdminService { }; } + rpc InspectPolicies(cerbos.request.v1.InspectPoliciesRequest) returns (cerbos.response.v1.InspectPoliciesResponse) { + option (google.api.http) = {get: "/admin/policies/inspect"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + summary: "Inspect policies in the store", + security: { + security_requirement: { + key: "BasicAuth"; + value: {}; + } + } + }; + } + rpc ListPolicies(cerbos.request.v1.ListPoliciesRequest) returns (cerbos.response.v1.ListPoliciesResponse) { option (google.api.http) = {get: "/admin/policies"}; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { diff --git a/proto/defs/cerbos/telemetry/v1/telemetry.proto b/proto/defs/cerbos/telemetry/v1/telemetry.proto index e971e21..2854ac9 100644 --- a/proto/defs/cerbos/telemetry/v1/telemetry.proto +++ b/proto/defs/cerbos/telemetry/v1/telemetry.proto @@ -1,4 +1,4 @@ -// Copyright 2021-2023 Zenauth Ltd. +// Copyright 2021-2024 Zenauth Ltd. // SPDX-License-Identifier: Apache-2.0 syntax = "proto3"; diff --git a/proto/defs/google/api/field_behavior.proto b/proto/defs/google/api/field_behavior.proto index 1a3a2f2..344cb0b 100644 --- a/proto/defs/google/api/field_behavior.proto +++ b/proto/defs/google/api/field_behavior.proto @@ -87,4 +87,18 @@ enum FieldBehavior { // a non-empty value will be returned. The user will not be aware of what // non-empty value to expect. NON_EMPTY_DEFAULT = 7; + + // Denotes that the field in a resource (a message annotated with + // google.api.resource) is used in the resource name to uniquely identify the + // resource. For AIP-compliant APIs, this should only be applied to the + // `name` field on the resource. + // + // This behavior should not be applied to references to other resources within + // the message. + // + // The identifier field of resources often have different field behavior + // depending on the request it is embedded in (e.g. for Create methods name + // is optional and unused, while for Update methods it is required). Instead + // of method-specific annotations, only `IDENTIFIER` is required. + IDENTIFIER = 8; } diff --git a/proto/defs/protoc-gen-openapiv2/options/openapiv2.proto b/proto/defs/protoc-gen-openapiv2/options/openapiv2.proto index 34ddb52..9a17f02 100644 --- a/proto/defs/protoc-gen-openapiv2/options/openapiv2.proto +++ b/proto/defs/protoc-gen-openapiv2/options/openapiv2.proto @@ -34,7 +34,7 @@ enum Scheme { // }; // license: { // name: "BSD 3-Clause License"; -// url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE.txt"; +// url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; // }; // }; // schemes: HTTPS; @@ -309,7 +309,7 @@ message Response { // }; // license: { // name: "BSD 3-Clause License"; -// url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE.txt"; +// url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; // }; // }; // ... @@ -377,7 +377,7 @@ message Contact { // ... // license: { // name: "BSD 3-Clause License"; -// url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE.txt"; +// url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; // }; // ... // }; diff --git a/proto/defs/validate/validate.proto b/proto/defs/validate/validate.proto deleted file mode 100644 index 705d382..0000000 --- a/proto/defs/validate/validate.proto +++ /dev/null @@ -1,862 +0,0 @@ -syntax = "proto2"; -package validate; - -option go_package = "github.com/envoyproxy/protoc-gen-validate/validate"; -option java_package = "io.envoyproxy.pgv.validate"; - -import "google/protobuf/descriptor.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -// Validation rules applied at the message level -extend google.protobuf.MessageOptions { - // Disabled nullifies any validation rules for this message, including any - // message fields associated with it that do support validation. - optional bool disabled = 1071; - // Ignore skips generation of validation methods for this message. - optional bool ignored = 1072; -} - -// Validation rules applied at the oneof level -extend google.protobuf.OneofOptions { - // Required ensures that exactly one the field options in a oneof is set; - // validation fails if no fields in the oneof are set. - optional bool required = 1071; -} - -// Validation rules applied at the field level -extend google.protobuf.FieldOptions { - // Rules specify the validations to be performed on this field. By default, - // no validation is performed against a field. - optional FieldRules rules = 1071; -} - -// FieldRules encapsulates the rules for each type of field. Depending on the -// field, the correct set should be used to ensure proper validations. -message FieldRules { - optional MessageRules message = 17; - 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; - } -} - -// FloatRules describes the constraints applied to `float` values -message FloatRules { - // Const specifies that this field must be exactly the specified value - optional float const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional float lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional float lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional float gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional float gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated float in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated float not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// DoubleRules describes the constraints applied to `double` values -message DoubleRules { - // Const specifies that this field must be exactly the specified value - optional double const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional double lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional double lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional double gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional double gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated double in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated double not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// Int32Rules describes the constraints applied to `int32` values -message Int32Rules { - // Const specifies that this field must be exactly the specified value - optional int32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional int32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional int32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional int32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional int32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated int32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated int32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// Int64Rules describes the constraints applied to `int64` values -message Int64Rules { - // Const specifies that this field must be exactly the specified value - optional int64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional int64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional int64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional int64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional int64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated int64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated int64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// UInt32Rules describes the constraints applied to `uint32` values -message UInt32Rules { - // Const specifies that this field must be exactly the specified value - optional uint32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional uint32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional uint32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional uint32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional uint32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated uint32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated uint32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// UInt64Rules describes the constraints applied to `uint64` values -message UInt64Rules { - // Const specifies that this field must be exactly the specified value - optional uint64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional uint64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional uint64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional uint64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional uint64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated uint64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated uint64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// SInt32Rules describes the constraints applied to `sint32` values -message SInt32Rules { - // Const specifies that this field must be exactly the specified value - optional sint32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional sint32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional sint32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional sint32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional sint32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated sint32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated sint32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// SInt64Rules describes the constraints applied to `sint64` values -message SInt64Rules { - // Const specifies that this field must be exactly the specified value - optional sint64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional sint64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional sint64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional sint64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional sint64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated sint64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated sint64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// Fixed32Rules describes the constraints applied to `fixed32` values -message Fixed32Rules { - // Const specifies that this field must be exactly the specified value - optional fixed32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional fixed32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional fixed32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional fixed32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional fixed32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated fixed32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated fixed32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// Fixed64Rules describes the constraints applied to `fixed64` values -message Fixed64Rules { - // Const specifies that this field must be exactly the specified value - optional fixed64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional fixed64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional fixed64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional fixed64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional fixed64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated fixed64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated fixed64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// SFixed32Rules describes the constraints applied to `sfixed32` values -message SFixed32Rules { - // Const specifies that this field must be exactly the specified value - optional sfixed32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional sfixed32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional sfixed32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional sfixed32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional sfixed32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated sfixed32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated sfixed32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// SFixed64Rules describes the constraints applied to `sfixed64` values -message SFixed64Rules { - // Const specifies that this field must be exactly the specified value - optional sfixed64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional sfixed64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional sfixed64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional sfixed64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional sfixed64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated sfixed64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated sfixed64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// BoolRules describes the constraints applied to `bool` values -message BoolRules { - // Const specifies that this field must be exactly the specified value - optional bool const = 1; -} - -// StringRules describe the constraints applied to `string` values -message StringRules { - // Const specifies that this field must be exactly the specified value - optional string const = 1; - - // Len specifies that this field must be the specified number of - // characters (Unicode code points). Note that the number of - // characters may differ from the number of bytes in the string. - optional uint64 len = 19; - - // MinLen specifies that this field must be the specified number of - // characters (Unicode code points) at a minimum. Note that the number of - // characters may differ from the number of bytes in the string. - optional uint64 min_len = 2; - - // MaxLen specifies that this field must be the specified number of - // characters (Unicode code points) at a maximum. Note that the number of - // characters may differ from the number of bytes in the string. - optional uint64 max_len = 3; - - // LenBytes specifies that this field must be the specified number of bytes - optional uint64 len_bytes = 20; - - // MinBytes specifies that this field must be the specified number of bytes - // at a minimum - optional uint64 min_bytes = 4; - - // MaxBytes specifies that this field must be the specified number of bytes - // at a maximum - optional uint64 max_bytes = 5; - - // Pattern specifes that this field must match against the specified - // regular expression (RE2 syntax). The included expression should elide - // any delimiters. - optional string pattern = 6; - - // Prefix specifies that this field must have the specified substring at - // the beginning of the string. - optional string prefix = 7; - - // Suffix specifies that this field must have the specified substring at - // the end of the string. - optional string suffix = 8; - - // Contains specifies that this field must have the specified substring - // anywhere in the string. - optional string contains = 9; - - // NotContains specifies that this field cannot have the specified substring - // anywhere in the string. - optional string not_contains = 23; - - // In specifies that this field must be equal to one of the specified - // values - repeated string in = 10; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated string not_in = 11; - - // WellKnown rules provide advanced constraints against common string - // patterns - oneof well_known { - // Email specifies that the field must be a valid email address as - // defined by RFC 5322 - bool email = 12; - - // Hostname specifies that the field must be a valid hostname as - // defined by RFC 1034. This constraint does not support - // internationalized domain names (IDNs). - bool hostname = 13; - - // Ip specifies that the field must be a valid IP (v4 or v6) address. - // Valid IPv6 addresses should not include surrounding square brackets. - bool ip = 14; - - // Ipv4 specifies that the field must be a valid IPv4 address. - bool ipv4 = 15; - - // Ipv6 specifies that the field must be a valid IPv6 address. Valid - // IPv6 addresses should not include surrounding square brackets. - bool ipv6 = 16; - - // Uri specifies that the field must be a valid, absolute URI as defined - // by RFC 3986 - bool uri = 17; - - // UriRef specifies that the field must be a valid URI as defined by RFC - // 3986 and may be relative or absolute. - bool uri_ref = 18; - - // Address specifies that the field must be either a valid hostname as - // defined by RFC 1034 (which does not support internationalized domain - // names or IDNs), or it can be a valid IP (v4 or v6). - bool address = 21; - - // Uuid specifies that the field must be a valid UUID as defined by - // RFC 4122 - bool uuid = 22; - - // WellKnownRegex specifies a common well known pattern defined as a regex. - KnownRegex well_known_regex = 24; - } - - // 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. - // Setting to false will enable a looser validations that only disallows - // \r\n\0 characters, which can be used to bypass header matching rules. - optional bool strict = 25 [default = true]; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 26; -} - -// WellKnownRegex contain some well-known patterns. -enum KnownRegex { - UNKNOWN = 0; - - // HTTP header name as defined by RFC 7230. - HTTP_HEADER_NAME = 1; - - // HTTP header value as defined by RFC 7230. - HTTP_HEADER_VALUE = 2; -} - -// BytesRules describe the constraints applied to `bytes` values -message BytesRules { - // Const specifies that this field must be exactly the specified value - optional bytes const = 1; - - // Len specifies that this field must be the specified number of bytes - optional uint64 len = 13; - - // MinLen specifies that this field must be the specified number of bytes - // at a minimum - optional uint64 min_len = 2; - - // MaxLen specifies that this field must be the specified number of bytes - // at a maximum - optional uint64 max_len = 3; - - // Pattern specifes that this field must match against the specified - // regular expression (RE2 syntax). The included expression should elide - // any delimiters. - optional string pattern = 4; - - // Prefix specifies that this field must have the specified bytes at the - // beginning of the string. - optional bytes prefix = 5; - - // Suffix specifies that this field must have the specified bytes at the - // end of the string. - optional bytes suffix = 6; - - // Contains specifies that this field must have the specified bytes - // anywhere in the string. - optional bytes contains = 7; - - // In specifies that this field must be equal to one of the specified - // values - repeated bytes in = 8; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated bytes not_in = 9; - - // WellKnown rules provide advanced constraints against common byte - // patterns - oneof well_known { - // Ip specifies that the field must be a valid IP (v4 or v6) address in - // byte format - bool ip = 10; - - // Ipv4 specifies that the field must be a valid IPv4 address in byte - // format - bool ipv4 = 11; - - // Ipv6 specifies that the field must be a valid IPv6 address in byte - // format - bool ipv6 = 12; - } - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 14; -} - -// EnumRules describe the constraints applied to enum values -message EnumRules { - // Const specifies that this field must be exactly the specified value - optional int32 const = 1; - - // DefinedOnly specifies that this field must be only one of the defined - // values for this enum, failing on any undefined value. - optional bool defined_only = 2; - - // In specifies that this field must be equal to one of the specified - // values - repeated int32 in = 3; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated int32 not_in = 4; -} - -// MessageRules describe the constraints applied to embedded message values. -// For message-type fields, validation is performed recursively. -message MessageRules { - // Skip specifies that the validation rules of this field should not be - // evaluated - optional bool skip = 1; - - // Required specifies that this field must be set - optional bool required = 2; -} - -// RepeatedRules describe the constraints applied to `repeated` values -message RepeatedRules { - // MinItems specifies that this field must have the specified number of - // items at a minimum - optional uint64 min_items = 1; - - // MaxItems specifies that this field must have the specified number of - // items at a maximum - optional uint64 max_items = 2; - - // Unique specifies that all elements in this field must be unique. This - // contraint is only applicable to scalar and enum types (messages are not - // supported). - optional bool unique = 3; - - // Items specifies the contraints to be applied to each item in the field. - // Repeated message fields will still execute validation against each item - // unless skip is specified here. - optional FieldRules items = 4; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 5; -} - -// MapRules describe the constraints applied to `map` values -message MapRules { - // MinPairs specifies that this field must have the specified number of - // KVs at a minimum - optional uint64 min_pairs = 1; - - // MaxPairs specifies that this field must have the specified number of - // KVs at a maximum - optional uint64 max_pairs = 2; - - // NoSparse specifies values in this field cannot be unset. This only - // applies to map's with message value types. - optional bool no_sparse = 3; - - // Keys specifies the constraints to be applied to each key in the field. - optional FieldRules keys = 4; - - // Values 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. - optional FieldRules values = 5; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 6; -} - -// AnyRules describe constraints applied exclusively to the -// `google.protobuf.Any` well-known type -message AnyRules { - // Required specifies that this field must be set - optional bool required = 1; - - // In specifies that this field's `type_url` must be equal to one of the - // specified values. - repeated string in = 2; - - // NotIn specifies that this field's `type_url` must not be equal to any of - // the specified values. - repeated string not_in = 3; -} - -// DurationRules describe the constraints applied exclusively to the -// `google.protobuf.Duration` well-known type -message DurationRules { - // Required specifies that this field must be set - optional bool required = 1; - - // Const specifies that this field must be exactly the specified value - optional google.protobuf.Duration const = 2; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional google.protobuf.Duration lt = 3; - - // Lt specifies that this field must be less than the specified value, - // inclusive - optional google.protobuf.Duration lte = 4; - - // Gt specifies that this field must be greater than the specified value, - // exclusive - optional google.protobuf.Duration gt = 5; - - // Gte specifies that this field must be greater than the specified value, - // inclusive - optional google.protobuf.Duration gte = 6; - - // In specifies that this field must be equal to one of the specified - // values - repeated google.protobuf.Duration in = 7; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated google.protobuf.Duration not_in = 8; -} - -// TimestampRules describe the constraints applied exclusively to the -// `google.protobuf.Timestamp` well-known type -message TimestampRules { - // Required specifies that this field must be set - optional bool required = 1; - - // Const specifies that this field must be exactly the specified value - optional google.protobuf.Timestamp const = 2; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional google.protobuf.Timestamp lt = 3; - - // Lte specifies that this field must be less than the specified value, - // inclusive - optional google.protobuf.Timestamp lte = 4; - - // Gt specifies that this field must be greater than the specified value, - // exclusive - optional google.protobuf.Timestamp gt = 5; - - // Gte specifies that this field must be greater than the specified value, - // inclusive - optional google.protobuf.Timestamp gte = 6; - - // LtNow specifies that this must be less than the current time. LtNow - // can only be used with the Within rule. - optional bool lt_now = 7; - - // GtNow specifies that this must be greater than the current time. GtNow - // can only be used with the Within rule. - optional bool gt_now = 8; - - // Within specifies that this field must be within this duration of the - // current time. This constraint can be used alone or with the LtNow and - // GtNow rules. - optional google.protobuf.Duration within = 9; -} diff --git a/src/genpb/buf.validate.r#priv.rs b/src/genpb/buf.validate.r#priv.rs new file mode 100644 index 0000000..4d542f9 --- /dev/null +++ b/src/genpb/buf.validate.r#priv.rs @@ -0,0 +1,18 @@ +/// Do not use. Internal to protovalidate library +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FieldConstraints { + #[prost(message, repeated, tag = "1")] + pub cel: ::prost::alloc::vec::Vec, +} +/// Do not use. Internal to protovalidate library +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Constraint { + #[prost(string, tag = "1")] + pub id: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub message: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub expression: ::prost::alloc::string::String, +} diff --git a/src/genpb/buf.validate.rs b/src/genpb/buf.validate.rs new file mode 100644 index 0000000..085ea9b --- /dev/null +++ b/src/genpb/buf.validate.rs @@ -0,0 +1,2808 @@ +/// `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](). +/// +/// ```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; +/// } +/// ``` +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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. + #[prost(string, tag = "1")] + pub id: ::prost::alloc::string::String, + /// `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. + #[prost(string, tag = "2")] + pub message: ::prost::alloc::string::String, + /// `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. + #[prost(string, tag = "3")] + pub expression: ::prost::alloc::string::String, +} +/// `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. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Violations { + /// `violations` is a repeated field that contains all the `Violation` messages corresponding to the violations detected. + #[prost(message, repeated, tag = "1")] + pub violations: ::prost::alloc::vec::Vec, +} +/// `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" +/// } +/// ``` +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Violation { + /// `field_path` is a machine-readable identifier that points to the specific field that failed the 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. + #[prost(string, tag = "1")] + pub field_path: ::prost::alloc::string::String, + /// `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. + #[prost(string, tag = "2")] + pub constraint_id: ::prost::alloc::string::String, + /// `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. + #[prost(string, tag = "3")] + pub message: ::prost::alloc::string::String, + /// `for_key` indicates whether the violation was caused by a map key, rather than a value. + #[prost(bool, tag = "4")] + pub for_key: bool, +} +/// 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. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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; + /// } + /// ``` + #[prost(bool, optional, tag = "1")] + pub disabled: ::core::option::Option, + /// `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](). + /// + /// + /// ```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; + /// } + /// ``` + #[prost(message, repeated, tag = "3")] + pub cel: ::prost::alloc::vec::Vec, +} +/// The `OneofConstraints` message type enables you to manage constraints for +/// oneof fields in your protobuf messages. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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; + /// } + /// } + /// ``` + #[prost(bool, optional, tag = "1")] + pub required: ::core::option::Option, +} +/// FieldRules encapsulates the rules for each type of field. Depending on the +/// field, the correct set should be used to ensure proper validations. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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](). + /// + /// ```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", + /// }]; + /// } + /// ``` + #[prost(message, repeated, tag = "23")] + pub cel: ::prost::alloc::vec::Vec, + /// `skipped` is an optional boolean attribute that specifies that the + /// validation rules of this field should not be evaluated. If skipped is set to + /// true, any validation rules set for the field will be ignored. + /// + /// ```proto + /// message MyMessage { + /// // The field `value` must not be set. + /// optional MyOtherMessage value = 1 \[(buf.validate.field).skipped = true\]; + /// } + /// ``` + #[prost(bool, tag = "24")] + pub skipped: bool, + /// If `required` is true, the field must be populated. Field presence can be + /// described as "serialized in the wire format," which follows the following rules: + /// + /// - the following "nullable" fields must be explicitly set to be considered present: + /// - singular message fields (may be their empty value) + /// - member fields of a oneof (may be their default value) + /// - proto3 optional fields (may be their default value) + /// - proto2 scalar fields + /// - proto3 scalar fields must be non-zero to be considered present + /// - repeated and map fields must be non-empty to be considered present + /// + /// ```proto + /// message MyMessage { + /// // The field `value` must be set to a non-null value. + /// optional MyOtherMessage value = 1 \[(buf.validate.field).required = true\]; + /// } + /// ``` + #[prost(bool, tag = "25")] + pub required: bool, + /// If `ignore_empty` is true and applied to a non-nullable field (see + /// `required` for more details), validation is skipped on the field if it is + /// the default or empty value. Adding `ignore_empty` to a "nullable" field is + /// a noop as these unset fields already skip validation (with the exception + /// of `required`). + /// + /// ```proto + /// message MyRepeated { + /// // The field `value` min_len rule is only applied if the field isn't empty. + /// repeated string value = 1 [ + /// (buf.validate.field).ignore_empty = true, + /// (buf.validate.field).min_len = 5 + /// ]; + /// } + /// ``` + #[prost(bool, tag = "26")] + pub ignore_empty: bool, + #[prost( + oneof = "field_constraints::Type", + tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22" + )] + pub r#type: ::core::option::Option, +} +/// Nested message and enum types in `FieldConstraints`. +pub mod field_constraints { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Type { + /// Scalar Field Types + #[prost(message, tag = "1")] + Float(super::FloatRules), + #[prost(message, tag = "2")] + Double(super::DoubleRules), + #[prost(message, tag = "3")] + Int32(super::Int32Rules), + #[prost(message, tag = "4")] + Int64(super::Int64Rules), + #[prost(message, tag = "5")] + Uint32(super::UInt32Rules), + #[prost(message, tag = "6")] + Uint64(super::UInt64Rules), + #[prost(message, tag = "7")] + Sint32(super::SInt32Rules), + #[prost(message, tag = "8")] + Sint64(super::SInt64Rules), + #[prost(message, tag = "9")] + Fixed32(super::Fixed32Rules), + #[prost(message, tag = "10")] + Fixed64(super::Fixed64Rules), + #[prost(message, tag = "11")] + Sfixed32(super::SFixed32Rules), + #[prost(message, tag = "12")] + Sfixed64(super::SFixed64Rules), + #[prost(message, tag = "13")] + Bool(super::BoolRules), + #[prost(message, tag = "14")] + String(super::StringRules), + #[prost(message, tag = "15")] + Bytes(super::BytesRules), + /// Complex Field Types + #[prost(message, tag = "16")] + Enum(super::EnumRules), + #[prost(message, tag = "18")] + Repeated(::prost::alloc::boxed::Box), + #[prost(message, tag = "19")] + Map(::prost::alloc::boxed::Box), + /// Well-Known Field Types + #[prost(message, tag = "20")] + Any(super::AnyRules), + #[prost(message, tag = "21")] + Duration(super::DurationRules), + #[prost(message, tag = "22")] + Timestamp(super::TimestampRules), + } +} +/// FloatRules describes the constraints applied to `float` values. These +/// rules may also be applied to the `google.protobuf.FloatValue` Well-Known-Type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(float, optional, tag = "1")] + pub r#const: ::core::option::Option, + /// `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\] }; + /// } + /// ``` + #[prost(float, repeated, packed = "false", tag = "6")] + pub r#in: ::prost::alloc::vec::Vec, + /// `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\] }; + /// } + /// ``` + #[prost(float, repeated, packed = "false", tag = "7")] + pub not_in: ::prost::alloc::vec::Vec, + /// `finite` requires the field value to be finite. If the field value is + /// infinite or NaN, an error message is generated. + #[prost(bool, tag = "8")] + pub finite: bool, + #[prost(oneof = "float_rules::LessThan", tags = "2, 3")] + pub less_than: ::core::option::Option, + #[prost(oneof = "float_rules::GreaterThan", tags = "4, 5")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `FloatRules`. +pub mod float_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// `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\]; + /// } + /// ``` + #[prost(float, tag = "2")] + Lt(f32), + /// `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\]; + /// } + /// ``` + #[prost(float, tag = "3")] + Lte(f32), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 }\]; + /// } + /// ``` + #[prost(float, tag = "4")] + Gt(f32), + /// `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 }\]; + /// } + /// ``` + #[prost(float, tag = "5")] + Gte(f32), + } +} +/// DoubleRules describes the constraints applied to `double` values. These +/// rules may also be applied to the `google.protobuf.DoubleValue` Well-Known-Type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(double, optional, tag = "1")] + pub r#const: ::core::option::Option, + /// `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\] }; + /// } + /// ``` + #[prost(double, repeated, packed = "false", tag = "6")] + pub r#in: ::prost::alloc::vec::Vec, + /// `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\] }; + /// } + /// ``` + #[prost(double, repeated, packed = "false", tag = "7")] + pub not_in: ::prost::alloc::vec::Vec, + /// `finite` requires the field value to be finite. If the field value is + /// infinite or NaN, an error message is generated. + #[prost(bool, tag = "8")] + pub finite: bool, + #[prost(oneof = "double_rules::LessThan", tags = "2, 3")] + pub less_than: ::core::option::Option, + #[prost(oneof = "double_rules::GreaterThan", tags = "4, 5")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `DoubleRules`. +pub mod double_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// `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\]; + /// } + /// ``` + #[prost(double, tag = "2")] + Lt(f64), + /// `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\]; + /// } + /// ``` + #[prost(double, tag = "3")] + Lte(f64), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 }\]; + /// } + /// ``` + #[prost(double, tag = "4")] + Gt(f64), + /// `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 }\]; + /// } + /// ``` + #[prost(double, tag = "5")] + Gte(f64), + } +} +/// Int32Rules describes the constraints applied to `int32` values. These +/// rules may also be applied to the `google.protobuf.Int32Value` Well-Known-Type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(int32, optional, tag = "1")] + pub r#const: ::core::option::Option, + /// `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\] }; + /// } + /// ``` + #[prost(int32, repeated, packed = "false", tag = "6")] + pub r#in: ::prost::alloc::vec::Vec, + /// `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\] }; + /// } + /// ``` + #[prost(int32, repeated, packed = "false", tag = "7")] + pub not_in: ::prost::alloc::vec::Vec, + #[prost(oneof = "int32_rules::LessThan", tags = "2, 3")] + pub less_than: ::core::option::Option, + #[prost(oneof = "int32_rules::GreaterThan", tags = "4, 5")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `Int32Rules`. +pub mod int32_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// `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\]; + /// } + /// ``` + #[prost(int32, tag = "2")] + Lt(i32), + /// `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\]; + /// } + /// ``` + #[prost(int32, tag = "3")] + Lte(i32), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 }\]; + /// } + /// ``` + #[prost(int32, tag = "4")] + Gt(i32), + /// `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 }\]; + /// } + /// ``` + #[prost(int32, tag = "5")] + Gte(i32), + } +} +/// Int64Rules describes the constraints applied to `int64` values. These +/// rules may also be applied to the `google.protobuf.Int64Value` Well-Known-Type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(int64, optional, tag = "1")] + pub r#const: ::core::option::Option, + /// `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\] }; + /// } + /// ``` + #[prost(int64, repeated, packed = "false", tag = "6")] + pub r#in: ::prost::alloc::vec::Vec, + /// `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\] }; + /// } + /// ``` + #[prost(int64, repeated, packed = "false", tag = "7")] + pub not_in: ::prost::alloc::vec::Vec, + #[prost(oneof = "int64_rules::LessThan", tags = "2, 3")] + pub less_than: ::core::option::Option, + #[prost(oneof = "int64_rules::GreaterThan", tags = "4, 5")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `Int64Rules`. +pub mod int64_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// `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\]; + /// } + /// ``` + #[prost(int64, tag = "2")] + Lt(i64), + /// `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\]; + /// } + /// ``` + #[prost(int64, tag = "3")] + Lte(i64), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 }\]; + /// } + /// ``` + #[prost(int64, tag = "4")] + Gt(i64), + /// `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 }\]; + /// } + /// ``` + #[prost(int64, tag = "5")] + Gte(i64), + } +} +/// UInt32Rules describes the constraints applied to `uint32` values. These +/// rules may also be applied to the `google.protobuf.UInt32Value` Well-Known-Type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(uint32, optional, tag = "1")] + pub r#const: ::core::option::Option, + /// `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\] }; + /// } + /// ``` + #[prost(uint32, repeated, packed = "false", tag = "6")] + pub r#in: ::prost::alloc::vec::Vec, + /// `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\] }; + /// } + /// ``` + #[prost(uint32, repeated, packed = "false", tag = "7")] + pub not_in: ::prost::alloc::vec::Vec, + #[prost(oneof = "u_int32_rules::LessThan", tags = "2, 3")] + pub less_than: ::core::option::Option, + #[prost(oneof = "u_int32_rules::GreaterThan", tags = "4, 5")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `UInt32Rules`. +pub mod u_int32_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// `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\]; + /// } + /// ``` + #[prost(uint32, tag = "2")] + Lt(u32), + /// `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\]; + /// } + /// ``` + #[prost(uint32, tag = "3")] + Lte(u32), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 }\]; + /// } + /// ``` + #[prost(uint32, tag = "4")] + Gt(u32), + /// `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 }\]; + /// } + /// ``` + #[prost(uint32, tag = "5")] + Gte(u32), + } +} +/// UInt64Rules describes the constraints applied to `uint64` values. These +/// rules may also be applied to the `google.protobuf.UInt64Value` Well-Known-Type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(uint64, optional, tag = "1")] + pub r#const: ::core::option::Option, + /// `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\] }; + /// } + /// ``` + #[prost(uint64, repeated, packed = "false", tag = "6")] + pub r#in: ::prost::alloc::vec::Vec, + /// `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\] }; + /// } + /// ``` + #[prost(uint64, repeated, packed = "false", tag = "7")] + pub not_in: ::prost::alloc::vec::Vec, + #[prost(oneof = "u_int64_rules::LessThan", tags = "2, 3")] + pub less_than: ::core::option::Option, + #[prost(oneof = "u_int64_rules::GreaterThan", tags = "4, 5")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `UInt64Rules`. +pub mod u_int64_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// `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\]; + /// } + /// ``` + #[prost(uint64, tag = "2")] + Lt(u64), + /// `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\]; + /// } + /// ``` + #[prost(uint64, tag = "3")] + Lte(u64), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 }\]; + /// } + /// ``` + #[prost(uint64, tag = "4")] + Gt(u64), + /// `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 }\]; + /// } + /// ``` + #[prost(uint64, tag = "5")] + Gte(u64), + } +} +/// SInt32Rules describes the constraints applied to `sint32` values. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(sint32, optional, tag = "1")] + pub r#const: ::core::option::Option, + /// `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\] }; + /// } + /// ``` + #[prost(sint32, repeated, packed = "false", tag = "6")] + pub r#in: ::prost::alloc::vec::Vec, + /// `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\] }; + /// } + /// ``` + #[prost(sint32, repeated, packed = "false", tag = "7")] + pub not_in: ::prost::alloc::vec::Vec, + #[prost(oneof = "s_int32_rules::LessThan", tags = "2, 3")] + pub less_than: ::core::option::Option, + #[prost(oneof = "s_int32_rules::GreaterThan", tags = "4, 5")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `SInt32Rules`. +pub mod s_int32_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// `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\]; + /// } + /// ``` + #[prost(sint32, tag = "2")] + Lt(i32), + /// `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\]; + /// } + /// ``` + #[prost(sint32, tag = "3")] + Lte(i32), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 }\]; + /// } + /// ``` + #[prost(sint32, tag = "4")] + Gt(i32), + /// `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 }\]; + /// } + /// ``` + #[prost(sint32, tag = "5")] + Gte(i32), + } +} +/// SInt64Rules describes the constraints applied to `sint64` values. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(sint64, optional, tag = "1")] + pub r#const: ::core::option::Option, + /// `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\] }; + /// } + /// ``` + #[prost(sint64, repeated, packed = "false", tag = "6")] + pub r#in: ::prost::alloc::vec::Vec, + /// `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\] }; + /// } + /// ``` + #[prost(sint64, repeated, packed = "false", tag = "7")] + pub not_in: ::prost::alloc::vec::Vec, + #[prost(oneof = "s_int64_rules::LessThan", tags = "2, 3")] + pub less_than: ::core::option::Option, + #[prost(oneof = "s_int64_rules::GreaterThan", tags = "4, 5")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `SInt64Rules`. +pub mod s_int64_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// `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\]; + /// } + /// ``` + #[prost(sint64, tag = "2")] + Lt(i64), + /// `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\]; + /// } + /// ``` + #[prost(sint64, tag = "3")] + Lte(i64), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 }\]; + /// } + /// ``` + #[prost(sint64, tag = "4")] + Gt(i64), + /// `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 }\]; + /// } + /// ``` + #[prost(sint64, tag = "5")] + Gte(i64), + } +} +/// Fixed32Rules describes the constraints applied to `fixed32` values. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(fixed32, optional, tag = "1")] + pub r#const: ::core::option::Option, + /// `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\] }; + /// } + /// ``` + #[prost(fixed32, repeated, packed = "false", tag = "6")] + pub r#in: ::prost::alloc::vec::Vec, + /// `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\] }; + /// } + /// ``` + #[prost(fixed32, repeated, packed = "false", tag = "7")] + pub not_in: ::prost::alloc::vec::Vec, + #[prost(oneof = "fixed32_rules::LessThan", tags = "2, 3")] + pub less_than: ::core::option::Option, + #[prost(oneof = "fixed32_rules::GreaterThan", tags = "4, 5")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `Fixed32Rules`. +pub mod fixed32_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// `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\]; + /// } + /// ``` + #[prost(fixed32, tag = "2")] + Lt(u32), + /// `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\]; + /// } + /// ``` + #[prost(fixed32, tag = "3")] + Lte(u32), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 }\]; + /// } + /// ``` + #[prost(fixed32, tag = "4")] + Gt(u32), + /// `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 }\]; + /// } + /// ``` + #[prost(fixed32, tag = "5")] + Gte(u32), + } +} +/// Fixed64Rules describes the constraints applied to `fixed64` values. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(fixed64, optional, tag = "1")] + pub r#const: ::core::option::Option, + /// `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\] }; + /// } + /// ``` + #[prost(fixed64, repeated, packed = "false", tag = "6")] + pub r#in: ::prost::alloc::vec::Vec, + /// `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\] }; + /// } + /// ``` + #[prost(fixed64, repeated, packed = "false", tag = "7")] + pub not_in: ::prost::alloc::vec::Vec, + #[prost(oneof = "fixed64_rules::LessThan", tags = "2, 3")] + pub less_than: ::core::option::Option, + #[prost(oneof = "fixed64_rules::GreaterThan", tags = "4, 5")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `Fixed64Rules`. +pub mod fixed64_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// `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\]; + /// } + /// ``` + #[prost(fixed64, tag = "2")] + Lt(u64), + /// `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\]; + /// } + /// ``` + #[prost(fixed64, tag = "3")] + Lte(u64), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 }\]; + /// } + /// ``` + #[prost(fixed64, tag = "4")] + Gt(u64), + /// `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 }\]; + /// } + /// ``` + #[prost(fixed64, tag = "5")] + Gte(u64), + } +} +/// SFixed32Rules describes the constraints applied to `fixed32` values. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(sfixed32, optional, tag = "1")] + pub r#const: ::core::option::Option, + /// `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\] }; + /// } + /// ``` + #[prost(sfixed32, repeated, packed = "false", tag = "6")] + pub r#in: ::prost::alloc::vec::Vec, + /// `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\] }; + /// } + /// ``` + #[prost(sfixed32, repeated, packed = "false", tag = "7")] + pub not_in: ::prost::alloc::vec::Vec, + #[prost(oneof = "s_fixed32_rules::LessThan", tags = "2, 3")] + pub less_than: ::core::option::Option, + #[prost(oneof = "s_fixed32_rules::GreaterThan", tags = "4, 5")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `SFixed32Rules`. +pub mod s_fixed32_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// `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\]; + /// } + /// ``` + #[prost(sfixed32, tag = "2")] + Lt(i32), + /// `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\]; + /// } + /// ``` + #[prost(sfixed32, tag = "3")] + Lte(i32), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 }\]; + /// } + /// ``` + #[prost(sfixed32, tag = "4")] + Gt(i32), + /// `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 }\]; + /// } + /// ``` + #[prost(sfixed32, tag = "5")] + Gte(i32), + } +} +/// SFixed64Rules describes the constraints applied to `fixed64` values. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(sfixed64, optional, tag = "1")] + pub r#const: ::core::option::Option, + /// `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\] }; + /// } + /// ``` + #[prost(sfixed64, repeated, packed = "false", tag = "6")] + pub r#in: ::prost::alloc::vec::Vec, + /// `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\] }; + /// } + /// ``` + #[prost(sfixed64, repeated, packed = "false", tag = "7")] + pub not_in: ::prost::alloc::vec::Vec, + #[prost(oneof = "s_fixed64_rules::LessThan", tags = "2, 3")] + pub less_than: ::core::option::Option, + #[prost(oneof = "s_fixed64_rules::GreaterThan", tags = "4, 5")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `SFixed64Rules`. +pub mod s_fixed64_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// `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\]; + /// } + /// ``` + #[prost(sfixed64, tag = "2")] + Lt(i64), + /// `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\]; + /// } + /// ``` + #[prost(sfixed64, tag = "3")] + Lte(i64), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 }\]; + /// } + /// ``` + #[prost(sfixed64, tag = "4")] + Gt(i64), + /// `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 }\]; + /// } + /// ``` + #[prost(sfixed64, tag = "5")] + Gte(i64), + } +} +/// BoolRules describes the constraints applied to `bool` values. These rules +/// may also be applied to the `google.protobuf.BoolValue` Well-Known-Type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(bool, optional, tag = "1")] + pub r#const: ::core::option::Option, +} +/// StringRules describes the constraints applied to `string` values These +/// rules may also be applied to the `google.protobuf.StringValue` Well-Known-Type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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"\]; + /// } + /// ``` + #[prost(string, optional, tag = "1")] + pub r#const: ::core::option::Option<::prost::alloc::string::String>, + /// `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\]; + /// } + /// ``` + #[prost(uint64, optional, tag = "19")] + pub len: ::core::option::Option, + /// `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\]; + /// } + /// ``` + #[prost(uint64, optional, tag = "2")] + pub min_len: ::core::option::Option, + /// `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\]; + /// } + /// ``` + #[prost(uint64, optional, tag = "3")] + pub max_len: ::core::option::Option, + /// `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\]; + /// } + /// ``` + #[prost(uint64, optional, tag = "20")] + pub len_bytes: ::core::option::Option, + /// `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\]; + /// } + /// + /// ``` + #[prost(uint64, optional, tag = "4")] + pub min_bytes: ::core::option::Option, + /// `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\]; + /// } + /// ``` + #[prost(uint64, optional, tag = "5")] + pub max_bytes: ::core::option::Option, + /// `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\]//$"]; + /// } + /// ``` + #[prost(string, optional, tag = "6")] + pub pattern: ::core::option::Option<::prost::alloc::string::String>, + /// `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"\]; + /// } + /// ``` + #[prost(string, optional, tag = "7")] + pub prefix: ::core::option::Option<::prost::alloc::string::String>, + /// `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"\]; + /// } + /// ``` + #[prost(string, optional, tag = "8")] + pub suffix: ::core::option::Option<::prost::alloc::string::String>, + /// `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"\]; + /// } + /// ``` + #[prost(string, optional, tag = "9")] + pub contains: ::core::option::Option<::prost::alloc::string::String>, + /// `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"\]; + /// } + /// ``` + #[prost(string, optional, tag = "23")] + pub not_contains: ::core::option::Option<::prost::alloc::string::String>, + /// `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"\]; + /// } + /// ``` + #[prost(string, repeated, tag = "10")] + pub r#in: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// `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"\]; + /// } + /// ``` + #[prost(string, repeated, tag = "11")] + pub not_in: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// 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](). 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\]; + /// } + /// ``` + #[prost(bool, optional, tag = "25")] + pub strict: ::core::option::Option, + /// `WellKnown` rules provide advanced constraints against common string + /// patterns + #[prost( + oneof = "string_rules::WellKnown", + tags = "12, 13, 14, 15, 16, 17, 18, 21, 22, 26, 27, 28, 29, 30, 31, 24" + )] + pub well_known: ::core::option::Option, +} +/// Nested message and enum types in `StringRules`. +pub mod string_rules { + /// `WellKnown` rules provide advanced constraints against common string + /// patterns + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum WellKnown { + /// `email` specifies that the field value must be a valid email address + /// (addr-spec only) as defined by [RFC 5322](). + /// 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\]; + /// } + /// ``` + #[prost(bool, tag = "12")] + Email(bool), + /// `hostname` specifies that the field value must be a valid + /// hostname as defined by [RFC 1034](). 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\]; + /// } + /// ``` + #[prost(bool, tag = "13")] + Hostname(bool), + /// `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\]; + /// } + /// ``` + #[prost(bool, tag = "14")] + Ip(bool), + /// `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\]; + /// } + /// ``` + #[prost(bool, tag = "15")] + Ipv4(bool), + /// `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\]; + /// } + /// ``` + #[prost(bool, tag = "16")] + Ipv6(bool), + /// `uri` specifies that the field value must be a valid, + /// absolute URI as defined by [RFC 3986](). 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\]; + /// } + /// ``` + #[prost(bool, tag = "17")] + Uri(bool), + /// `uri_ref` specifies that the field value must be a valid URI + /// as defined by [RFC 3986]() 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\]; + /// } + /// ``` + #[prost(bool, tag = "18")] + UriRef(bool), + /// `address` specifies that the field value must be either a valid hostname + /// as defined by [RFC 1034]() + /// (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\]; + /// } + /// ``` + #[prost(bool, tag = "21")] + Address(bool), + /// `uuid` specifies that the field value must be a valid UUID as defined by + /// [RFC 4122](). 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\]; + /// } + /// ``` + #[prost(bool, tag = "22")] + Uuid(bool), + /// `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\]; + /// } + /// ``` + #[prost(bool, tag = "26")] + IpWithPrefixlen(bool), + /// `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 lentgh + /// string value = 1 \[(buf.validate.field).string.ipv4_with_prefixlen = true\]; + /// } + /// ``` + #[prost(bool, tag = "27")] + Ipv4WithPrefixlen(bool), + /// `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\]; + /// } + /// ``` + #[prost(bool, tag = "28")] + Ipv6WithPrefixlen(bool), + /// `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\]; + /// } + /// ``` + #[prost(bool, tag = "29")] + IpPrefix(bool), + /// `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\]; + /// } + /// ``` + #[prost(bool, tag = "30")] + Ipv4Prefix(bool), + /// `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\]; + /// } + /// ``` + #[prost(bool, tag = "31")] + Ipv6Prefix(bool), + /// `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 = 2\]; + /// } + /// ``` + /// + /// #### 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]() | + /// | KNOWN_REGEX_HTTP_HEADER_VALUE | 2 | HTTP header value as defined by [RFC 7230]() | + #[prost(enumeration = "super::KnownRegex", tag = "24")] + WellKnownRegex(i32), + } +} +/// BytesRules describe the constraints applied to `bytes` values. These rules +/// may also be applied to the `google.protobuf.BytesValue` Well-Known-Type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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"\]; + /// } + /// ``` + #[prost(bytes = "vec", optional, tag = "1")] + pub r#const: ::core::option::Option<::prost::alloc::vec::Vec>, + /// `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\]; + /// } + /// ``` + #[prost(uint64, optional, tag = "13")] + pub len: ::core::option::Option, + /// `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\]; + /// } + /// ``` + #[prost(uint64, optional, tag = "2")] + pub min_len: ::core::option::Option, + /// `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\]; + /// } + /// ``` + #[prost(uint64, optional, tag = "3")] + pub max_len: ::core::option::Option, + /// `pattern` requires the field value to match the specified regular + /// expression ([RE2 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\]+$"]; + /// } + /// ``` + #[prost(string, optional, tag = "4")] + pub pattern: ::core::option::Option<::prost::alloc::string::String>, + /// `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"\]; + /// } + /// ``` + #[prost(bytes = "vec", optional, tag = "5")] + pub prefix: ::core::option::Option<::prost::alloc::vec::Vec>, + /// `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"\]; + /// } + /// ``` + #[prost(bytes = "vec", optional, tag = "6")] + pub suffix: ::core::option::Option<::prost::alloc::vec::Vec>, + /// `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"\]; + /// } + /// ``` + #[prost(bytes = "vec", optional, tag = "7")] + pub contains: ::core::option::Option<::prost::alloc::vec::Vec>, + /// `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"}\]; + /// } + /// ``` + #[prost(bytes = "vec", repeated, tag = "8")] + pub r#in: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + /// `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"}\]; + /// } + /// ``` + #[prost(bytes = "vec", repeated, tag = "9")] + pub not_in: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + /// WellKnown rules provide advanced constraints against common byte + /// patterns + #[prost(oneof = "bytes_rules::WellKnown", tags = "10, 11, 12")] + pub well_known: ::core::option::Option, +} +/// Nested message and enum types in `BytesRules`. +pub mod bytes_rules { + /// WellKnown rules provide advanced constraints against common byte + /// patterns + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum WellKnown { + /// `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\]; + /// } + /// ``` + #[prost(bool, tag = "10")] + Ip(bool), + /// `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\]; + /// } + /// ``` + #[prost(bool, tag = "11")] + Ipv4(bool), + /// `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\]; + /// } + /// ``` + #[prost(bool, tag = "12")] + Ipv6(bool), + } +} +/// EnumRules describe the constraints applied to `enum` values. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(int32, optional, tag = "1")] + pub r#const: ::core::option::Option, + /// `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\]; + /// } + /// ``` + #[prost(bool, optional, tag = "2")] + pub defined_only: ::core::option::Option, + /// `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\]}]; + /// } + /// ``` + #[prost(int32, repeated, packed = "false", tag = "3")] + pub r#in: ::prost::alloc::vec::Vec, + /// `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\]}]; + /// } + /// ``` + #[prost(int32, repeated, packed = "false", tag = "4")] + pub not_in: ::prost::alloc::vec::Vec, +} +/// RepeatedRules describe the constraints applied to `repeated` values. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(uint64, optional, tag = "1")] + pub min_items: ::core::option::Option, + /// `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\]; + /// } + /// ``` + #[prost(uint64, optional, tag = "2")] + pub max_items: ::core::option::Option, + /// `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\]; + /// } + /// ``` + #[prost(bool, optional, tag = "3")] + pub unique: ::core::option::Option, + /// `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 + /// } + /// }]; + /// } + /// ``` + #[prost(message, optional, boxed, tag = "4")] + pub items: ::core::option::Option<::prost::alloc::boxed::Box>, +} +/// MapRules describe the constraints applied to `map` values. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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\]; + /// } + /// ``` + #[prost(uint64, optional, tag = "1")] + pub min_pairs: ::core::option::Option, + /// 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\]; + /// } + /// ``` + #[prost(uint64, optional, tag = "2")] + pub max_pairs: ::core::option::Option, + /// 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 + /// } + /// }]; + /// } + /// ``` + #[prost(message, optional, boxed, tag = "4")] + pub keys: ::core::option::Option<::prost::alloc::boxed::Box>, + /// 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 + /// } + /// }]; + /// } + /// ``` + #[prost(message, optional, boxed, tag = "5")] + pub values: ::core::option::Option<::prost::alloc::boxed::Box>, +} +/// AnyRules describe constraints applied exclusively to the `google.protobuf.Any` well-known type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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"]\]; + /// } + /// ``` + #[prost(string, repeated, tag = "2")] + pub r#in: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + /// 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"]\]; + /// } + /// ``` + #[prost(string, repeated, tag = "3")] + pub not_in: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +/// DurationRules describe the constraints applied exclusively to the `google.protobuf.Duration` well-known type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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"\]; + /// } + /// ``` + #[prost(message, optional, tag = "2")] + pub r#const: ::core::option::Option<::prost_types::Duration>, + /// `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"]\]; + /// } + /// ``` + #[prost(message, repeated, tag = "7")] + pub r#in: ::prost::alloc::vec::Vec<::prost_types::Duration>, + /// `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"]\]; + /// } + /// ``` + #[prost(message, repeated, tag = "8")] + pub not_in: ::prost::alloc::vec::Vec<::prost_types::Duration>, + #[prost(oneof = "duration_rules::LessThan", tags = "3, 4")] + pub less_than: ::core::option::Option, + #[prost(oneof = "duration_rules::GreaterThan", tags = "5, 6")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `DurationRules`. +pub mod duration_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// `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"\]; + /// } + /// ``` + #[prost(message, tag = "3")] + Lt(::prost_types::Duration), + /// `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"\]; + /// } + /// ``` + #[prost(message, tag = "4")] + Lte(::prost_types::Duration), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 } }\]; + /// } + /// ``` + #[prost(message, tag = "5")] + Gt(::prost_types::Duration), + /// `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 } }\]; + /// } + /// ``` + #[prost(message, tag = "6")] + Gte(::prost_types::Duration), + } +} +/// TimestampRules describe the constraints applied exclusively to the `google.protobuf.Timestamp` well-known type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct 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}\]; + /// } + /// ``` + #[prost(message, optional, tag = "2")] + pub r#const: ::core::option::Option<::prost_types::Timestamp>, + /// `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}\]; + /// } + /// ``` + #[prost(message, optional, tag = "9")] + pub within: ::core::option::Option<::prost_types::Duration>, + #[prost(oneof = "timestamp_rules::LessThan", tags = "3, 4, 7")] + pub less_than: ::core::option::Option, + #[prost(oneof = "timestamp_rules::GreaterThan", tags = "5, 6, 8")] + pub greater_than: ::core::option::Option, +} +/// Nested message and enum types in `TimestampRules`. +pub mod timestamp_rules { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum LessThan { + /// 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 }\]; + /// } + /// ``` + #[prost(message, tag = "3")] + Lt(::prost_types::Timestamp), + /// 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 }\]; + /// } + /// ``` + #[prost(message, tag = "4")] + Lte(::prost_types::Timestamp), + /// `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\]; + /// } + /// ``` + #[prost(bool, tag = "7")] + LtNow(bool), + } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum GreaterThan { + /// `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 } }\]; + /// } + /// ``` + #[prost(message, tag = "5")] + Gt(::prost_types::Timestamp), + /// `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 } }\]; + /// } + /// ``` + #[prost(message, tag = "6")] + Gte(::prost_types::Timestamp), + /// `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\]; + /// } + /// ``` + #[prost(bool, tag = "8")] + GtNow(bool), + } +} +/// WellKnownRegex contain some well-known patterns. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum KnownRegex { + Unspecified = 0, + /// HTTP header name as defined by [RFC 7230](). + HttpHeaderName = 1, + /// HTTP header value as defined by [RFC 7230](). + HttpHeaderValue = 2, +} +impl KnownRegex { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + KnownRegex::Unspecified => "KNOWN_REGEX_UNSPECIFIED", + KnownRegex::HttpHeaderName => "KNOWN_REGEX_HTTP_HEADER_NAME", + KnownRegex::HttpHeaderValue => "KNOWN_REGEX_HTTP_HEADER_VALUE", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "KNOWN_REGEX_UNSPECIFIED" => Some(Self::Unspecified), + "KNOWN_REGEX_HTTP_HEADER_NAME" => Some(Self::HttpHeaderName), + "KNOWN_REGEX_HTTP_HEADER_VALUE" => Some(Self::HttpHeaderValue), + _ => None, + } + } +} diff --git a/src/genpb/cerbos.audit.v1.rs b/src/genpb/cerbos.audit.v1.rs index 635bc14..a81f024 100644 --- a/src/genpb/cerbos.audit.v1.rs +++ b/src/genpb/cerbos.audit.v1.rs @@ -40,6 +40,8 @@ pub struct DecisionLogEntry { ::prost::alloc::string::String, MetaValues, >, + #[prost(message, optional, tag = "16")] + pub audit_trail: ::core::option::Option, #[prost(oneof = "decision_log_entry::Method", tags = "7, 8")] pub method: ::core::option::Option, } @@ -100,3 +102,12 @@ pub struct Peer { #[prost(string, tag = "4")] pub forwarded_for: ::prost::alloc::string::String, } +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AuditTrail { + #[prost(map = "string, message", tag = "1")] + pub effective_policies: ::std::collections::HashMap< + ::prost::alloc::string::String, + super::super::policy::v1::SourceAttributes, + >, +} diff --git a/src/genpb/cerbos.policy.v1.rs b/src/genpb/cerbos.policy.v1.rs index a822dcc..544043b 100644 --- a/src/genpb/cerbos.policy.v1.rs +++ b/src/genpb/cerbos.policy.v1.rs @@ -36,6 +36,15 @@ pub mod policy { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct SourceAttributes { + #[prost(map = "string, message", tag = "1")] + pub attributes: ::std::collections::HashMap< + ::prost::alloc::string::String, + ::prost_types::Value, + >, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct Metadata { #[prost(string, tag = "1")] pub source_file: ::prost::alloc::string::String, @@ -51,6 +60,8 @@ pub struct Metadata { pub store_identifer: ::prost::alloc::string::String, #[prost(string, tag = "5")] pub store_identifier: ::prost::alloc::string::String, + #[prost(message, optional, tag = "6")] + pub source_attributes: ::core::option::Option, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -216,8 +227,22 @@ pub mod r#match { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Output { + #[deprecated] #[prost(string, tag = "1")] pub expr: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub when: ::core::option::Option, +} +/// Nested message and enum types in `Output`. +pub mod output { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct When { + #[prost(string, tag = "1")] + pub rule_activated: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub condition_not_met: ::prost::alloc::string::String, + } } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -288,6 +313,13 @@ pub mod test_fixture { pub struct TestOptions { #[prost(message, optional, tag = "1")] pub now: ::core::option::Option<::prost_types::Timestamp>, + #[prost(bool, tag = "2")] + pub lenient_scope_search: bool, + #[prost(map = "string, message", tag = "3")] + pub globals: ::std::collections::HashMap< + ::prost::alloc::string::String, + ::prost_types::Value, + >, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -513,7 +545,7 @@ pub mod test_results { pub engine_trace: ::prost::alloc::vec::Vec< super::super::super::engine::v1::Trace, >, - #[prost(oneof = "details::Outcome", tags = "2, 3")] + #[prost(oneof = "details::Outcome", tags = "2, 3, 5")] pub outcome: ::core::option::Option, } /// Nested message and enum types in `Details`. @@ -525,6 +557,8 @@ pub mod test_results { Failure(super::Failure), #[prost(string, tag = "3")] Error(::prost::alloc::string::String), + #[prost(message, tag = "5")] + Success(super::Success), } } #[allow(clippy::derive_partial_eq_without_eq)] @@ -570,6 +604,16 @@ pub mod test_results { #[prost(message, repeated, tag = "3")] pub outputs: ::prost::alloc::vec::Vec, } + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Success { + #[prost(enumeration = "super::super::super::effect::v1::Effect", tag = "1")] + pub effect: i32, + #[prost(message, repeated, tag = "2")] + pub outputs: ::prost::alloc::vec::Vec< + super::super::super::engine::v1::OutputEntry, + >, + } #[derive( Clone, Copy, diff --git a/src/genpb/cerbos.request.v1.rs b/src/genpb/cerbos.request.v1.rs index f3cd06d..8fef943 100644 --- a/src/genpb/cerbos.request.v1.rs +++ b/src/genpb/cerbos.request.v1.rs @@ -300,6 +300,18 @@ pub struct EnablePolicyRequest { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct InspectPoliciesRequest { + #[prost(bool, tag = "1")] + pub include_disabled: bool, + #[prost(string, tag = "2")] + pub name_regexp: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub scope_regexp: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub version_regexp: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct AddOrUpdateSchemaRequest { #[prost(message, repeated, tag = "1")] pub schemas: ::prost::alloc::vec::Vec, diff --git a/src/genpb/cerbos.response.v1.rs b/src/genpb/cerbos.response.v1.rs index 69b1f0b..2c507a7 100644 --- a/src/genpb/cerbos.response.v1.rs +++ b/src/genpb/cerbos.response.v1.rs @@ -17,6 +17,8 @@ pub struct PlanResourcesResponse { pub validation_errors: ::prost::alloc::vec::Vec< super::super::schema::v1::ValidationError, >, + #[prost(string, tag = "8")] + pub cerbos_call_id: ::prost::alloc::string::String, } /// Nested message and enum types in `PlanResourcesResponse`. pub mod plan_resources_response { @@ -128,6 +130,8 @@ pub struct CheckResourcesResponse { pub request_id: ::prost::alloc::string::String, #[prost(message, repeated, tag = "2")] pub results: ::prost::alloc::vec::Vec, + #[prost(string, tag = "3")] + pub cerbos_call_id: ::prost::alloc::string::String, } /// Nested message and enum types in `CheckResourcesResponse`. pub mod check_resources_response { @@ -200,6 +204,16 @@ pub struct PlaygroundFailure { } /// Nested message and enum types in `PlaygroundFailure`. pub mod playground_failure { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ErrorDetails { + #[prost(uint32, tag = "1")] + pub line: u32, + #[prost(uint32, tag = "2")] + pub column: u32, + #[prost(string, tag = "3")] + pub context: ::prost::alloc::string::String, + } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Error { @@ -207,6 +221,8 @@ pub mod playground_failure { pub file: ::prost::alloc::string::String, #[prost(string, tag = "2")] pub error: ::prost::alloc::string::String, + #[prost(message, optional, tag = "3")] + pub details: ::core::option::Option, } } #[allow(clippy::derive_partial_eq_without_eq)] @@ -396,6 +412,24 @@ pub struct EnablePolicyResponse { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct InspectPoliciesResponse { + #[prost(map = "string, message", tag = "1")] + pub results: ::std::collections::HashMap< + ::prost::alloc::string::String, + inspect_policies_response::Result, + >, +} +/// Nested message and enum types in `InspectPoliciesResponse`. +pub mod inspect_policies_response { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Result { + #[prost(string, repeated, tag = "1")] + pub actions: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct AddOrUpdateSchemaResponse {} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/src/genpb/cerbos.svc.v1.rs b/src/genpb/cerbos.svc.v1.rs index da29fe1..027dc56 100644 --- a/src/genpb/cerbos.svc.v1.rs +++ b/src/genpb/cerbos.svc.v1.rs @@ -347,6 +347,38 @@ pub mod cerbos_admin_service_client { ); self.inner.unary(req, path, codec).await } + pub async fn inspect_policies( + &mut self, + request: impl tonic::IntoRequest< + super::super::super::request::v1::InspectPoliciesRequest, + >, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/cerbos.svc.v1.CerbosAdminService/InspectPolicies", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "cerbos.svc.v1.CerbosAdminService", + "InspectPolicies", + ), + ); + self.inner.unary(req, path, codec).await + } pub async fn list_policies( &mut self, request: impl tonic::IntoRequest< diff --git a/src/genpb/google.api.rs b/src/genpb/google.api.rs index f558514..ae88fb0 100644 --- a/src/genpb/google.api.rs +++ b/src/genpb/google.api.rs @@ -40,6 +40,19 @@ pub enum FieldBehavior { /// a non-empty value will be returned. The user will not be aware of what /// non-empty value to expect. NonEmptyDefault = 7, + /// Denotes that the field in a resource (a message annotated with + /// google.api.resource) is used in the resource name to uniquely identify the + /// resource. For AIP-compliant APIs, this should only be applied to the + /// `name` field on the resource. + /// + /// This behavior should not be applied to references to other resources within + /// the message. + /// + /// The identifier field of resources often have different field behavior + /// depending on the request it is embedded in (e.g. for Create methods name + /// is optional and unused, while for Update methods it is required). Instead + /// of method-specific annotations, only `IDENTIFIER` is required. + Identifier = 8, } impl FieldBehavior { /// String value of the enum field names used in the ProtoBuf definition. @@ -56,6 +69,7 @@ impl FieldBehavior { FieldBehavior::Immutable => "IMMUTABLE", FieldBehavior::UnorderedList => "UNORDERED_LIST", FieldBehavior::NonEmptyDefault => "NON_EMPTY_DEFAULT", + FieldBehavior::Identifier => "IDENTIFIER", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -69,6 +83,7 @@ impl FieldBehavior { "IMMUTABLE" => Some(Self::Immutable), "UNORDERED_LIST" => Some(Self::UnorderedList), "NON_EMPTY_DEFAULT" => Some(Self::NonEmptyDefault), + "IDENTIFIER" => Some(Self::Identifier), _ => None, } } diff --git a/src/genpb/grpc.gateway.protoc_gen_openapiv2.options.rs b/src/genpb/grpc.gateway.protoc_gen_openapiv2.options.rs index 087e82c..f9ca7e8 100644 --- a/src/genpb/grpc.gateway.protoc_gen_openapiv2.options.rs +++ b/src/genpb/grpc.gateway.protoc_gen_openapiv2.options.rs @@ -16,7 +16,7 @@ /// }; /// license: { /// name: "BSD 3-Clause License"; -/// url: " +/// url: " /// }; /// }; /// schemes: HTTPS; @@ -354,7 +354,7 @@ pub struct Response { /// }; /// license: { /// name: "BSD 3-Clause License"; -/// url: " +/// url: " /// }; /// }; /// ... @@ -437,7 +437,7 @@ pub struct Contact { /// ... /// license: { /// name: "BSD 3-Clause License"; -/// url: " +/// url: " /// }; /// ... /// };