diff --git a/proto/protovalidate-testing/buf/validate/conformance/cases/custom_constraints/custom_constraints.proto b/proto/protovalidate-testing/buf/validate/conformance/cases/custom_constraints/custom_constraints.proto index fb7ca318..80bf8b9c 100644 --- a/proto/protovalidate-testing/buf/validate/conformance/cases/custom_constraints/custom_constraints.proto +++ b/proto/protovalidate-testing/buf/validate/conformance/cases/custom_constraints/custom_constraints.proto @@ -87,6 +87,20 @@ message FieldExpressions { message: "c.a must be a multiple of 4" expression: "this.a % 4 == 0" }]; + int32 d = 4 [ + (field).cel = { + id: "field_expression_scalar_multiple_1" + expression: + "this < 1 ? ''" + ": 'd must be less than 1'" + }, + (field).cel = { + id: "field_expression_scalar_multiple_2" + expression: + "this < 2 ? ''" + ": 'd must be less than 2'" + } + ]; message Nested { int32 a = 1 [(field).cel = { diff --git a/proto/protovalidate/buf/validate/validate.proto b/proto/protovalidate/buf/validate/validate.proto index 53d3ba78..f24d8dff 100644 --- a/proto/protovalidate/buf/validate/validate.proto +++ b/proto/protovalidate/buf/validate/validate.proto @@ -4770,9 +4770,62 @@ message Violations { // } // ``` message Violation { - // `field_path` is a machine-readable identifier that points to the specific field that failed the validation. + // `field` is a machine-readable path to the field that failed validation. // This could be a nested field, in which case the path will include all the parent fields leading to the actual field that caused the violation. - optional string field_path = 1; + // + // For example, consider the following message: + // + // ```proto + // message Message { + // bool a = 1 [(buf.validate.field).required = true]; + // } + // ``` + // + // It could produce the following violation: + // + // ```textproto + // violation { + // field { element { field_number: 1, field_name: "a", field_type: 8 } } + // ... + // } + // ``` + optional FieldPath field = 5; + + // `rule` is a machine-readable path that points to the specific constraint rule that failed validation. + // This will be a nested field starting from the FieldConstraints of the field that failed validation. + // For custom constraints, this will provide the path of the constraint, e.g. `cel[0]`. + // + // For example, consider the following message: + // + // ```proto + // message Message { + // bool a = 1 [(buf.validate.field).required = true]; + // bool b = 2 [(buf.validate.field).cel = { + // id: "custom_constraint", + // expression: "!this ? 'b must be true': ''" + // }] + // } + // ``` + // + // It could produce the following violations: + // + // ```textproto + // violation { + // rule { element { field_number: 25, field_name: "required", field_type: 8 } } + // ... + // } + // violation { + // rule { element { field_number: 23, field_name: "cel", field_type: 11, index: 0 } } + // ... + // } + // ``` + optional FieldPath rule = 6; + + // `field_path` is a human-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. + // + // Deprecated: use the `field` instead. + optional string field_path = 1 [deprecated = true]; // `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. @@ -4785,3 +4838,65 @@ message Violation { // `for_key` indicates whether the violation was caused by a map key, rather than a value. optional bool for_key = 4; } + +// `FieldPath` provides a path to a nested protobuf field. +// +// This message provides enough information to render a dotted field path even without protobuf descriptors. +// It also provides enough information to resolve a nested field through unknown wire data. +message FieldPath { + // `elements` contains each element of the path, starting from the root and recursing downward. + repeated FieldPathElement elements = 1; +} + +// `FieldPathElement` provides enough information to nest through a single protobuf field. +// +// If the selected field is a map or repeated field, the `subscript` value selects a specific element from it. +// A path that refers to a value nested under a map key or repeated field index will have a `subscript` value. +// The `field_type` field allows unambiguous resolution of a field even if descriptors are not available. +message FieldPathElement { + // `field_number` is the field number this path element refers to. + optional int32 field_number = 1; + + // `field_name` contains the field name this path element refers to. + // This can be used to display a human-readable path even if the field number is unknown. + optional string field_name = 2; + + // `field_type` specifies the type of this field. When using reflection, this value is not needed. + // + // This value is provided to make it possible to traverse unknown fields through wire data. + // When traversing wire data, be mindful of both packed[1] and delimited[2] encoding schemes. + // + // [1]: https://protobuf.dev/programming-guides/encoding/#packed + // [2]: https://protobuf.dev/programming-guides/encoding/#groups + // + // N.B.: Although groups are deprecated, the corresponding delimited encoding scheme is not, and + // can be explicitly used in Protocol Buffers 2023 Edition. + optional google.protobuf.FieldDescriptorProto.Type field_type = 3; + + // `key_type` specifies the map key type of this field. This value is useful when traversing + // unknown fields through wire data: specifically, it allows handling the differences between + // different integer encodings. + optional google.protobuf.FieldDescriptorProto.Type key_type = 4; + + // `value_type` specifies map value type of this field. This is useful if you want to display a + // value inside unknown fields through wire data. + optional google.protobuf.FieldDescriptorProto.Type value_type = 5; + + // `subscript` contains a repeated index or map key, if this path element nests into a repeated or map field. + oneof subscript { + // `index` specifies a 0-based index into a repeated field. + uint64 index = 6; + + // `bool_key` specifies a map key of type bool. + bool bool_key = 7; + + // `int_key` specifies a map key of type int32, int64, sint32, sint64, sfixed32 or sfixed64. + int64 int_key = 8; + + // `uint_key` specifies a map key of type uint32, uint64, fixed32 or fixed64. + uint64 uint_key = 9; + + // `string_key` specifies a map key of type string. + string string_key = 10; + } +} diff --git a/tools/internal/gen/buf/validate/conformance/cases/custom_constraints/custom_constraints.pb.go b/tools/internal/gen/buf/validate/conformance/cases/custom_constraints/custom_constraints.pb.go index 8da5f330..29ba7e99 100644 --- a/tools/internal/gen/buf/validate/conformance/cases/custom_constraints/custom_constraints.pb.go +++ b/tools/internal/gen/buf/validate/conformance/cases/custom_constraints/custom_constraints.pb.go @@ -241,6 +241,7 @@ type FieldExpressions struct { A int32 `protobuf:"varint,1,opt,name=a,proto3" json:"a,omitempty"` B Enum `protobuf:"varint,2,opt,name=b,proto3,enum=buf.validate.conformance.cases.custom_constraints.Enum" json:"b,omitempty"` C *FieldExpressions_Nested `protobuf:"bytes,3,opt,name=c,proto3" json:"c,omitempty"` + D int32 `protobuf:"varint,4,opt,name=d,proto3" json:"d,omitempty"` } func (x *FieldExpressions) Reset() { @@ -296,6 +297,13 @@ func (x *FieldExpressions) GetC() *FieldExpressions_Nested { return nil } +func (x *FieldExpressions) GetD() int32 { + if x != nil { + return x.D + } + return 0 +} + type MissingField struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -684,7 +692,7 @@ var file_buf_validate_conformance_cases_custom_constraints_custom_constraints_pr 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x12, 0x12, 0x65, 0x2e, 0x61, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x65, 0x71, 0x75, 0x61, 0x6c, 0x20, 0x66, 0x2e, 0x61, 0x1a, 0x14, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x65, 0x2e, 0x61, 0x20, 0x3d, - 0x3d, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x66, 0x2e, 0x61, 0x22, 0xf6, 0x03, 0x0a, 0x10, 0x46, + 0x3d, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x66, 0x2e, 0x61, 0x22, 0xaa, 0x05, 0x0a, 0x10, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x42, 0x4c, 0xba, 0x48, 0x49, 0xba, 0x01, 0x46, 0x0a, 0x17, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, @@ -710,68 +718,79 @@ var file_buf_validate_conformance_cases_custom_constraints_custom_constraints_pr 0x6d, 0x62, 0x65, 0x64, 0x12, 0x1b, 0x63, 0x2e, 0x61, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x61, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x34, 0x1a, 0x0f, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x61, 0x20, 0x25, 0x20, 0x34, 0x20, 0x3d, 0x3d, - 0x20, 0x30, 0x52, 0x01, 0x63, 0x1a, 0x5c, 0x0a, 0x06, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, - 0x52, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x42, 0x44, 0xba, 0x48, 0x41, 0xba, - 0x01, 0x3e, 0x0a, 0x17, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x1a, 0x23, 0x74, 0x68, 0x69, - 0x73, 0x20, 0x3e, 0x20, 0x30, 0x20, 0x3f, 0x20, 0x27, 0x27, 0x3a, 0x20, 0x27, 0x61, 0x20, 0x6d, - 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x27, - 0x52, 0x01, 0x61, 0x22, 0x52, 0x0a, 0x0c, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x46, 0x69, - 0x65, 0x6c, 0x64, 0x12, 0x0c, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, - 0x61, 0x3a, 0x34, 0xba, 0x48, 0x31, 0x1a, 0x2f, 0x0a, 0x0d, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, - 0x67, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x12, 0x62, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, - 0x62, 0x65, 0x20, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x1a, 0x0a, 0x74, 0x68, 0x69, - 0x73, 0x2e, 0x62, 0x20, 0x3e, 0x20, 0x30, 0x22, 0x67, 0x0a, 0x0d, 0x49, 0x6e, 0x63, 0x6f, 0x72, - 0x72, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x01, 0x61, 0x3a, 0x48, 0xba, 0x48, 0x45, 0x1a, 0x43, 0x0a, 0x0e, 0x69, - 0x6e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x12, 0x17, 0x61, - 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x20, 0x77, 0x69, 0x74, 0x68, - 0x20, 0x27, 0x66, 0x6f, 0x6f, 0x27, 0x1a, 0x18, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x61, 0x2e, 0x73, - 0x74, 0x61, 0x72, 0x74, 0x73, 0x57, 0x69, 0x74, 0x68, 0x28, 0x27, 0x66, 0x6f, 0x6f, 0x27, 0x29, - 0x22, 0x7d, 0x0a, 0x0f, 0x44, 0x79, 0x6e, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x45, 0x72, - 0x72, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, - 0x61, 0x3a, 0x5c, 0xba, 0x48, 0x59, 0x1a, 0x57, 0x0a, 0x0f, 0x64, 0x79, 0x6e, 0x5f, 0x72, 0x75, - 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x65, 0x72, 0x72, 0x12, 0x2e, 0x64, 0x79, 0x6e, 0x61, 0x6d, - 0x69, 0x63, 0x20, 0x74, 0x79, 0x70, 0x65, 0x20, 0x74, 0x72, 0x69, 0x65, 0x73, 0x20, 0x74, 0x6f, - 0x20, 0x75, 0x73, 0x65, 0x20, 0x61, 0x20, 0x6e, 0x6f, 0x6e, 0x2d, 0x65, 0x78, 0x69, 0x73, 0x74, - 0x65, 0x6e, 0x74, 0x20, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x1a, 0x14, 0x64, 0x79, 0x6e, 0x28, 0x74, - 0x68, 0x69, 0x73, 0x29, 0x2e, 0x62, 0x20, 0x3d, 0x3d, 0x20, 0x27, 0x66, 0x6f, 0x6f, 0x27, 0x22, - 0x5c, 0x0a, 0x0c, 0x4e, 0x6f, 0x77, 0x45, 0x71, 0x75, 0x61, 0x6c, 0x73, 0x4e, 0x6f, 0x77, 0x3a, - 0x4c, 0xba, 0x48, 0x49, 0x1a, 0x47, 0x0a, 0x0e, 0x6e, 0x6f, 0x77, 0x5f, 0x65, 0x71, 0x75, 0x61, - 0x6c, 0x73, 0x5f, 0x6e, 0x6f, 0x77, 0x12, 0x29, 0x6e, 0x6f, 0x77, 0x20, 0x73, 0x68, 0x6f, 0x75, - 0x6c, 0x64, 0x20, 0x65, 0x71, 0x75, 0x61, 0x6c, 0x20, 0x6e, 0x6f, 0x77, 0x20, 0x77, 0x69, 0x74, - 0x68, 0x69, 0x6e, 0x20, 0x61, 0x6e, 0x20, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x1a, 0x0a, 0x6e, 0x6f, 0x77, 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x6f, 0x77, 0x2a, 0x2a, 0x0a, - 0x04, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x55, 0x4e, - 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x45, - 0x4e, 0x55, 0x4d, 0x5f, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x42, 0x9d, 0x03, 0x0a, 0x35, 0x63, 0x6f, - 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x63, - 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, - 0x2e, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, - 0x6e, 0x74, 0x73, 0x42, 0x16, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x6f, 0x6e, 0x73, 0x74, - 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x66, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, - 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2f, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, - 0x67, 0x65, 0x6e, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2f, 0x63, 0x61, 0x73, - 0x65, 0x73, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x72, - 0x61, 0x69, 0x6e, 0x74, 0x73, 0xa2, 0x02, 0x05, 0x42, 0x56, 0x43, 0x43, 0x43, 0xaa, 0x02, 0x30, - 0x42, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x43, 0x6f, 0x6e, - 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x43, - 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, - 0xca, 0x02, 0x30, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, - 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x5c, 0x43, 0x61, 0x73, 0x65, - 0x73, 0x5c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, - 0x6e, 0x74, 0x73, 0xe2, 0x02, 0x3c, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x5c, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x5c, 0x43, - 0x61, 0x73, 0x65, 0x73, 0x5c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x6f, 0x6e, 0x73, 0x74, - 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x34, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x3a, 0x3a, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x3a, - 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x6f, - 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x20, 0x30, 0x52, 0x01, 0x63, 0x12, 0xb1, 0x01, 0x0a, 0x01, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x05, 0x42, 0xa2, 0x01, 0xba, 0x48, 0x9e, 0x01, 0xba, 0x01, 0x4c, 0x0a, 0x22, 0x66, 0x69, 0x65, + 0x6c, 0x64, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x63, + 0x61, 0x6c, 0x61, 0x72, 0x5f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x5f, 0x31, 0x1a, + 0x26, 0x74, 0x68, 0x69, 0x73, 0x20, 0x3c, 0x20, 0x31, 0x20, 0x3f, 0x20, 0x27, 0x27, 0x3a, 0x20, + 0x27, 0x64, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x6c, 0x65, 0x73, 0x73, 0x20, + 0x74, 0x68, 0x61, 0x6e, 0x20, 0x31, 0x27, 0xba, 0x01, 0x4c, 0x0a, 0x22, 0x66, 0x69, 0x65, 0x6c, + 0x64, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x63, 0x61, + 0x6c, 0x61, 0x72, 0x5f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x5f, 0x32, 0x1a, 0x26, + 0x74, 0x68, 0x69, 0x73, 0x20, 0x3c, 0x20, 0x32, 0x20, 0x3f, 0x20, 0x27, 0x27, 0x3a, 0x20, 0x27, + 0x64, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x6c, 0x65, 0x73, 0x73, 0x20, 0x74, + 0x68, 0x61, 0x6e, 0x20, 0x32, 0x27, 0x52, 0x01, 0x64, 0x1a, 0x5c, 0x0a, 0x06, 0x4e, 0x65, 0x73, + 0x74, 0x65, 0x64, 0x12, 0x52, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x42, 0x44, + 0xba, 0x48, 0x41, 0xba, 0x01, 0x3e, 0x0a, 0x17, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x65, 0x78, + 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x1a, + 0x23, 0x74, 0x68, 0x69, 0x73, 0x20, 0x3e, 0x20, 0x30, 0x20, 0x3f, 0x20, 0x27, 0x27, 0x3a, 0x20, + 0x27, 0x61, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x76, 0x65, 0x27, 0x52, 0x01, 0x61, 0x22, 0x52, 0x0a, 0x0c, 0x4d, 0x69, 0x73, 0x73, 0x69, + 0x6e, 0x67, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x0c, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x01, 0x61, 0x3a, 0x34, 0xba, 0x48, 0x31, 0x1a, 0x2f, 0x0a, 0x0d, 0x6d, 0x69, + 0x73, 0x73, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x12, 0x62, 0x20, 0x6d, + 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x1a, + 0x0a, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x62, 0x20, 0x3e, 0x20, 0x30, 0x22, 0x67, 0x0a, 0x0d, 0x49, + 0x6e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x01, + 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x61, 0x3a, 0x48, 0xba, 0x48, 0x45, 0x1a, + 0x43, 0x0a, 0x0e, 0x69, 0x6e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, + 0x65, 0x12, 0x17, 0x61, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x20, + 0x77, 0x69, 0x74, 0x68, 0x20, 0x27, 0x66, 0x6f, 0x6f, 0x27, 0x1a, 0x18, 0x74, 0x68, 0x69, 0x73, + 0x2e, 0x61, 0x2e, 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x57, 0x69, 0x74, 0x68, 0x28, 0x27, 0x66, + 0x6f, 0x6f, 0x27, 0x29, 0x22, 0x7d, 0x0a, 0x0f, 0x44, 0x79, 0x6e, 0x52, 0x75, 0x6e, 0x74, 0x69, + 0x6d, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x01, 0x61, 0x3a, 0x5c, 0xba, 0x48, 0x59, 0x1a, 0x57, 0x0a, 0x0f, 0x64, 0x79, + 0x6e, 0x5f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x65, 0x72, 0x72, 0x12, 0x2e, 0x64, + 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x20, 0x74, 0x79, 0x70, 0x65, 0x20, 0x74, 0x72, 0x69, 0x65, + 0x73, 0x20, 0x74, 0x6f, 0x20, 0x75, 0x73, 0x65, 0x20, 0x61, 0x20, 0x6e, 0x6f, 0x6e, 0x2d, 0x65, + 0x78, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x74, 0x20, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x1a, 0x14, 0x64, + 0x79, 0x6e, 0x28, 0x74, 0x68, 0x69, 0x73, 0x29, 0x2e, 0x62, 0x20, 0x3d, 0x3d, 0x20, 0x27, 0x66, + 0x6f, 0x6f, 0x27, 0x22, 0x5c, 0x0a, 0x0c, 0x4e, 0x6f, 0x77, 0x45, 0x71, 0x75, 0x61, 0x6c, 0x73, + 0x4e, 0x6f, 0x77, 0x3a, 0x4c, 0xba, 0x48, 0x49, 0x1a, 0x47, 0x0a, 0x0e, 0x6e, 0x6f, 0x77, 0x5f, + 0x65, 0x71, 0x75, 0x61, 0x6c, 0x73, 0x5f, 0x6e, 0x6f, 0x77, 0x12, 0x29, 0x6e, 0x6f, 0x77, 0x20, + 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x65, 0x71, 0x75, 0x61, 0x6c, 0x20, 0x6e, 0x6f, 0x77, + 0x20, 0x77, 0x69, 0x74, 0x68, 0x69, 0x6e, 0x20, 0x61, 0x6e, 0x20, 0x65, 0x78, 0x70, 0x72, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x0a, 0x6e, 0x6f, 0x77, 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x6f, + 0x77, 0x2a, 0x2a, 0x0a, 0x04, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x4e, 0x55, + 0x4d, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, + 0x0c, 0x0a, 0x08, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x42, 0x9d, 0x03, + 0x0a, 0x35, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x65, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x63, + 0x61, 0x73, 0x65, 0x73, 0x2e, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x63, 0x6f, 0x6e, 0x73, + 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x42, 0x16, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, + 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x66, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, + 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x2f, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, + 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x63, 0x6f, + 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0xa2, 0x02, 0x05, 0x42, 0x56, 0x43, 0x43, + 0x43, 0xaa, 0x02, 0x30, 0x42, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x73, + 0x65, 0x73, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, + 0x69, 0x6e, 0x74, 0x73, 0xca, 0x02, 0x30, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x65, 0x5c, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x5c, + 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x6f, 0x6e, 0x73, + 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0xe2, 0x02, 0x3c, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, + 0x63, 0x65, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, + 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x34, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x43, 0x6f, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, + 0x6e, 0x63, 0x65, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x43, 0x75, 0x73, 0x74, + 0x6f, 0x6d, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/tools/internal/gen/buf/validate/validate.pb.go b/tools/internal/gen/buf/validate/validate.pb.go index a52d4eac..6a967ac1 100644 --- a/tools/internal/gen/buf/validate/validate.pb.go +++ b/tools/internal/gen/buf/validate/validate.pb.go @@ -6766,8 +6766,70 @@ type Violation struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // `field_path` is a machine-readable identifier that points to the specific field that failed the validation. + // `field` is a machine-readable path to the field that failed validation. // This could be a nested field, in which case the path will include all the parent fields leading to the actual field that caused the violation. + // + // For example, consider the following message: + // + // ```proto + // + // message Message { + // bool a = 1 [(buf.validate.field).required = true]; + // } + // + // ``` + // + // It could produce the following violation: + // + // ```textproto + // + // violation { + // field { element { field_number: 1, field_name: "a", field_type: 8 } } + // ... + // } + // + // ``` + Field *FieldPath `protobuf:"bytes,5,opt,name=field" json:"field,omitempty"` + // `rule` is a machine-readable path that points to the specific constraint rule that failed validation. + // This will be a nested field starting from the FieldConstraints of the field that failed validation. + // For custom constraints, this will provide the path of the constraint, e.g. `cel[0]`. + // + // For example, consider the following message: + // + // ```proto + // + // message Message { + // bool a = 1 [(buf.validate.field).required = true]; + // bool b = 2 [(buf.validate.field).cel = { + // id: "custom_constraint", + // expression: "!this ? 'b must be true': ''" + // }] + // } + // + // ``` + // + // It could produce the following violations: + // + // ```textproto + // + // violation { + // rule { element { field_number: 25, field_name: "required", field_type: 8 } } + // ... + // } + // + // violation { + // rule { element { field_number: 23, field_name: "cel", field_type: 11, index: 0 } } + // ... + // } + // + // ``` + Rule *FieldPath `protobuf:"bytes,6,opt,name=rule" json:"rule,omitempty"` + // `field_path` is a human-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. + // + // Deprecated: use the `field` instead. + // + // Deprecated: Marked as deprecated in buf/validate/validate.proto. FieldPath *string `protobuf:"bytes,1,opt,name=field_path,json=fieldPath" json:"field_path,omitempty"` // `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. @@ -6811,6 +6873,21 @@ func (*Violation) Descriptor() ([]byte, []int) { return file_buf_validate_validate_proto_rawDescGZIP(), []int{27} } +func (x *Violation) GetField() *FieldPath { + if x != nil { + return x.Field + } + return nil +} + +func (x *Violation) GetRule() *FieldPath { + if x != nil { + return x.Rule + } + return nil +} + +// Deprecated: Marked as deprecated in buf/validate/validate.proto. func (x *Violation) GetFieldPath() string { if x != nil && x.FieldPath != nil { return *x.FieldPath @@ -6839,6 +6916,251 @@ func (x *Violation) GetForKey() bool { return false } +// `FieldPath` provides a path to a nested protobuf field. +// +// This message provides enough information to render a dotted field path even without protobuf descriptors. +// It also provides enough information to resolve a nested field through unknown wire data. +type FieldPath struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // `elements` contains each element of the path, starting from the root and recursing downward. + Elements []*FieldPathElement `protobuf:"bytes,1,rep,name=elements" json:"elements,omitempty"` +} + +func (x *FieldPath) Reset() { + *x = FieldPath{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_validate_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FieldPath) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FieldPath) ProtoMessage() {} + +func (x *FieldPath) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_validate_proto_msgTypes[28] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FieldPath.ProtoReflect.Descriptor instead. +func (*FieldPath) Descriptor() ([]byte, []int) { + return file_buf_validate_validate_proto_rawDescGZIP(), []int{28} +} + +func (x *FieldPath) GetElements() []*FieldPathElement { + if x != nil { + return x.Elements + } + return nil +} + +// `FieldPathElement` provides enough information to nest through a single protobuf field. +// +// If the selected field is a map or repeated field, the `subscript` value selects a specific element from it. +// A path that refers to a value nested under a map key or repeated field index will have a `subscript` value. +// The `field_type` field allows unambiguous resolution of a field even if descriptors are not available. +type FieldPathElement struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // `field_number` is the field number this path element refers to. + FieldNumber *int32 `protobuf:"varint,1,opt,name=field_number,json=fieldNumber" json:"field_number,omitempty"` + // `field_name` contains the field name this path element refers to. + // This can be used to display a human-readable path even if the field number is unknown. + FieldName *string `protobuf:"bytes,2,opt,name=field_name,json=fieldName" json:"field_name,omitempty"` + // `field_type` specifies the type of this field. When using reflection, this value is not needed. + // + // This value is provided to make it possible to traverse unknown fields through wire data. + // When traversing wire data, be mindful of both packed[1] and delimited[2] encoding schemes. + // + // N.B.: Although groups are deprecated, the corresponding delimited encoding scheme is not, and + // can be explicitly used in Protocol Buffers 2023 Edition. + // + // [1]: https://protobuf.dev/programming-guides/encoding/#packed + // [2]: https://protobuf.dev/programming-guides/encoding/#groups + FieldType *descriptorpb.FieldDescriptorProto_Type `protobuf:"varint,3,opt,name=field_type,json=fieldType,enum=google.protobuf.FieldDescriptorProto_Type" json:"field_type,omitempty"` + // `key_type` specifies the map key type of this field. This value is useful when traversing + // unknown fields through wire data: specifically, it allows handling the differences between + // different integer encodings. + KeyType *descriptorpb.FieldDescriptorProto_Type `protobuf:"varint,4,opt,name=key_type,json=keyType,enum=google.protobuf.FieldDescriptorProto_Type" json:"key_type,omitempty"` + // `value_type` specifies map value type of this field. This is useful if you want to display a + // value inside unknown fields through wire data. + ValueType *descriptorpb.FieldDescriptorProto_Type `protobuf:"varint,5,opt,name=value_type,json=valueType,enum=google.protobuf.FieldDescriptorProto_Type" json:"value_type,omitempty"` + // `subscript` contains a repeated index or map key, if this path element nests into a repeated or map field. + // + // Types that are assignable to Subscript: + // + // *FieldPathElement_Index + // *FieldPathElement_BoolKey + // *FieldPathElement_IntKey + // *FieldPathElement_UintKey + // *FieldPathElement_StringKey + Subscript isFieldPathElement_Subscript `protobuf_oneof:"subscript"` +} + +func (x *FieldPathElement) Reset() { + *x = FieldPathElement{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_validate_proto_msgTypes[29] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FieldPathElement) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FieldPathElement) ProtoMessage() {} + +func (x *FieldPathElement) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_validate_proto_msgTypes[29] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FieldPathElement.ProtoReflect.Descriptor instead. +func (*FieldPathElement) Descriptor() ([]byte, []int) { + return file_buf_validate_validate_proto_rawDescGZIP(), []int{29} +} + +func (x *FieldPathElement) GetFieldNumber() int32 { + if x != nil && x.FieldNumber != nil { + return *x.FieldNumber + } + return 0 +} + +func (x *FieldPathElement) GetFieldName() string { + if x != nil && x.FieldName != nil { + return *x.FieldName + } + return "" +} + +func (x *FieldPathElement) GetFieldType() descriptorpb.FieldDescriptorProto_Type { + if x != nil && x.FieldType != nil { + return *x.FieldType + } + return descriptorpb.FieldDescriptorProto_Type(1) +} + +func (x *FieldPathElement) GetKeyType() descriptorpb.FieldDescriptorProto_Type { + if x != nil && x.KeyType != nil { + return *x.KeyType + } + return descriptorpb.FieldDescriptorProto_Type(1) +} + +func (x *FieldPathElement) GetValueType() descriptorpb.FieldDescriptorProto_Type { + if x != nil && x.ValueType != nil { + return *x.ValueType + } + return descriptorpb.FieldDescriptorProto_Type(1) +} + +func (m *FieldPathElement) GetSubscript() isFieldPathElement_Subscript { + if m != nil { + return m.Subscript + } + return nil +} + +func (x *FieldPathElement) GetIndex() uint64 { + if x, ok := x.GetSubscript().(*FieldPathElement_Index); ok { + return x.Index + } + return 0 +} + +func (x *FieldPathElement) GetBoolKey() bool { + if x, ok := x.GetSubscript().(*FieldPathElement_BoolKey); ok { + return x.BoolKey + } + return false +} + +func (x *FieldPathElement) GetIntKey() int64 { + if x, ok := x.GetSubscript().(*FieldPathElement_IntKey); ok { + return x.IntKey + } + return 0 +} + +func (x *FieldPathElement) GetUintKey() uint64 { + if x, ok := x.GetSubscript().(*FieldPathElement_UintKey); ok { + return x.UintKey + } + return 0 +} + +func (x *FieldPathElement) GetStringKey() string { + if x, ok := x.GetSubscript().(*FieldPathElement_StringKey); ok { + return x.StringKey + } + return "" +} + +type isFieldPathElement_Subscript interface { + isFieldPathElement_Subscript() +} + +type FieldPathElement_Index struct { + // `index` specifies a 0-based index into a repeated field. + Index uint64 `protobuf:"varint,6,opt,name=index,oneof"` +} + +type FieldPathElement_BoolKey struct { + // `bool_key` specifies a map key of type bool. + BoolKey bool `protobuf:"varint,7,opt,name=bool_key,json=boolKey,oneof"` +} + +type FieldPathElement_IntKey struct { + // `int_key` specifies a map key of type int32, int64, sint32, sint64, sfixed32 or sfixed64. + IntKey int64 `protobuf:"varint,8,opt,name=int_key,json=intKey,oneof"` +} + +type FieldPathElement_UintKey struct { + // `uint_key` specifies a map key of type uint32, uint64, fixed32 or fixed64. + UintKey uint64 `protobuf:"varint,9,opt,name=uint_key,json=uintKey,oneof"` +} + +type FieldPathElement_StringKey struct { + // `string_key` specifies a map key of type string. + StringKey string `protobuf:"bytes,10,opt,name=string_key,json=stringKey,oneof"` +} + +func (*FieldPathElement_Index) isFieldPathElement_Subscript() {} + +func (*FieldPathElement_BoolKey) isFieldPathElement_Subscript() {} + +func (*FieldPathElement_IntKey) isFieldPathElement_Subscript() {} + +func (*FieldPathElement_UintKey) isFieldPathElement_Subscript() {} + +func (*FieldPathElement_StringKey) isFieldPathElement_Subscript() {} + var file_buf_validate_validate_proto_extTypes = []protoimpl.ExtensionInfo{ { ExtendedType: (*descriptorpb.MessageOptions)(nil), @@ -10217,66 +10539,106 @@ var file_buf_validate_validate_proto_rawDesc = []byte{ 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x56, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x76, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x22, 0x82, 0x01, 0x0a, 0x09, 0x56, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, - 0x0a, 0x0a, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x50, 0x61, 0x74, 0x68, 0x12, 0x23, 0x0a, + 0x22, 0xe2, 0x01, 0x0a, 0x09, 0x56, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, + 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x50, 0x61, 0x74, 0x68, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x2b, 0x0a, + 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x50, 0x61, 0x74, 0x68, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x21, 0x0a, 0x0a, 0x66, 0x69, + 0x65, 0x6c, 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x02, + 0x18, 0x01, 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x50, 0x61, 0x74, 0x68, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x6f, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x66, - 0x6f, 0x72, 0x4b, 0x65, 0x79, 0x2a, 0x9d, 0x01, 0x0a, 0x06, 0x49, 0x67, 0x6e, 0x6f, 0x72, 0x65, - 0x12, 0x16, 0x0a, 0x12, 0x49, 0x47, 0x4e, 0x4f, 0x52, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, - 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x49, 0x47, 0x4e, 0x4f, - 0x52, 0x45, 0x5f, 0x49, 0x46, 0x5f, 0x55, 0x4e, 0x50, 0x4f, 0x50, 0x55, 0x4c, 0x41, 0x54, 0x45, - 0x44, 0x10, 0x01, 0x12, 0x1b, 0x0a, 0x17, 0x49, 0x47, 0x4e, 0x4f, 0x52, 0x45, 0x5f, 0x49, 0x46, - 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, 0x10, 0x02, - 0x12, 0x11, 0x0a, 0x0d, 0x49, 0x47, 0x4e, 0x4f, 0x52, 0x45, 0x5f, 0x41, 0x4c, 0x57, 0x41, 0x59, - 0x53, 0x10, 0x03, 0x12, 0x14, 0x0a, 0x0c, 0x49, 0x47, 0x4e, 0x4f, 0x52, 0x45, 0x5f, 0x45, 0x4d, - 0x50, 0x54, 0x59, 0x10, 0x01, 0x1a, 0x02, 0x08, 0x01, 0x12, 0x16, 0x0a, 0x0e, 0x49, 0x47, 0x4e, - 0x4f, 0x52, 0x45, 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x10, 0x02, 0x1a, 0x02, 0x08, - 0x01, 0x1a, 0x02, 0x10, 0x01, 0x2a, 0x6e, 0x0a, 0x0a, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x52, 0x65, - 0x67, 0x65, 0x78, 0x12, 0x1b, 0x0a, 0x17, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x52, 0x45, 0x47, - 0x45, 0x58, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x20, 0x0a, 0x1c, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x52, 0x45, 0x47, 0x45, 0x58, 0x5f, - 0x48, 0x54, 0x54, 0x50, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x5f, 0x4e, 0x41, 0x4d, 0x45, - 0x10, 0x01, 0x12, 0x21, 0x0a, 0x1d, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x52, 0x45, 0x47, 0x45, - 0x58, 0x5f, 0x48, 0x54, 0x54, 0x50, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x5f, 0x56, 0x41, - 0x4c, 0x55, 0x45, 0x10, 0x02, 0x3a, 0x5c, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x18, 0x87, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, - 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x3a, 0x54, 0x0a, 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x12, 0x1d, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4f, - 0x6e, 0x65, 0x6f, 0x66, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x87, 0x09, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x65, 0x2e, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, - 0x74, 0x73, 0x52, 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x3a, 0x54, 0x0a, 0x05, 0x66, 0x69, 0x65, - 0x6c, 0x64, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x18, 0x87, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x6f, 0x6e, - 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x3a, - 0x63, 0x0a, 0x0a, 0x70, 0x72, 0x65, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x12, 0x1d, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x88, 0x09, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x2e, 0x50, 0x72, 0x65, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x43, 0x6f, 0x6e, - 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x64, 0x65, 0x66, - 0x69, 0x6e, 0x65, 0x64, 0x42, 0xb5, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, - 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x42, 0x0d, 0x56, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x74, 0x6f, - 0x6f, 0x6c, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, - 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0xa2, 0x02, 0x03, - 0x42, 0x56, 0x58, 0xaa, 0x02, 0x0c, 0x42, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0xca, 0x02, 0x0c, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x65, 0xe2, 0x02, 0x18, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0d, 0x42, - 0x75, 0x66, 0x3a, 0x3a, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x6f, 0x72, 0x4b, 0x65, 0x79, 0x22, 0x47, 0x0a, 0x09, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x50, 0x61, + 0x74, 0x68, 0x12, 0x3a, 0x0a, 0x08, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x65, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6c, 0x65, + 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xcc, + 0x03, 0x0a, 0x10, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6c, 0x65, 0x6d, + 0x65, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x66, 0x69, 0x65, 0x6c, 0x64, + 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, + 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x49, 0x0a, 0x0a, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, + 0x64, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x45, 0x0a, 0x08, 0x6b, 0x65, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x2a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x07, + 0x6b, 0x65, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x49, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2a, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, + 0x65, 0x6c, 0x64, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x16, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x04, 0x48, 0x00, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1b, 0x0a, 0x08, 0x62, 0x6f, + 0x6f, 0x6c, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x07, + 0x62, 0x6f, 0x6f, 0x6c, 0x4b, 0x65, 0x79, 0x12, 0x19, 0x0a, 0x07, 0x69, 0x6e, 0x74, 0x5f, 0x6b, + 0x65, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x06, 0x69, 0x6e, 0x74, 0x4b, + 0x65, 0x79, 0x12, 0x1b, 0x0a, 0x08, 0x75, 0x69, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x07, 0x75, 0x69, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x12, + 0x1f, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x0a, 0x20, + 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x09, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4b, 0x65, 0x79, + 0x42, 0x0b, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x2a, 0x9d, 0x01, + 0x0a, 0x06, 0x49, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x49, 0x47, 0x4e, 0x4f, + 0x52, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x19, 0x0a, 0x15, 0x49, 0x47, 0x4e, 0x4f, 0x52, 0x45, 0x5f, 0x49, 0x46, 0x5f, 0x55, 0x4e, + 0x50, 0x4f, 0x50, 0x55, 0x4c, 0x41, 0x54, 0x45, 0x44, 0x10, 0x01, 0x12, 0x1b, 0x0a, 0x17, 0x49, + 0x47, 0x4e, 0x4f, 0x52, 0x45, 0x5f, 0x49, 0x46, 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, + 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x49, 0x47, 0x4e, 0x4f, + 0x52, 0x45, 0x5f, 0x41, 0x4c, 0x57, 0x41, 0x59, 0x53, 0x10, 0x03, 0x12, 0x14, 0x0a, 0x0c, 0x49, + 0x47, 0x4e, 0x4f, 0x52, 0x45, 0x5f, 0x45, 0x4d, 0x50, 0x54, 0x59, 0x10, 0x01, 0x1a, 0x02, 0x08, + 0x01, 0x12, 0x16, 0x0a, 0x0e, 0x49, 0x47, 0x4e, 0x4f, 0x52, 0x45, 0x5f, 0x44, 0x45, 0x46, 0x41, + 0x55, 0x4c, 0x54, 0x10, 0x02, 0x1a, 0x02, 0x08, 0x01, 0x1a, 0x02, 0x10, 0x01, 0x2a, 0x6e, 0x0a, + 0x0a, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x67, 0x65, 0x78, 0x12, 0x1b, 0x0a, 0x17, 0x4b, + 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x52, 0x45, 0x47, 0x45, 0x58, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, + 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x20, 0x0a, 0x1c, 0x4b, 0x4e, 0x4f, 0x57, + 0x4e, 0x5f, 0x52, 0x45, 0x47, 0x45, 0x58, 0x5f, 0x48, 0x54, 0x54, 0x50, 0x5f, 0x48, 0x45, 0x41, + 0x44, 0x45, 0x52, 0x5f, 0x4e, 0x41, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x21, 0x0a, 0x1d, 0x4b, 0x4e, + 0x4f, 0x57, 0x4e, 0x5f, 0x52, 0x45, 0x47, 0x45, 0x58, 0x5f, 0x48, 0x54, 0x54, 0x50, 0x5f, 0x48, + 0x45, 0x41, 0x44, 0x45, 0x52, 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, 0x10, 0x02, 0x3a, 0x5c, 0x0a, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x87, 0x09, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x20, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, + 0x74, 0x73, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x3a, 0x54, 0x0a, 0x05, 0x6f, + 0x6e, 0x65, 0x6f, 0x66, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x87, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x62, 0x75, 0x66, + 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x43, + 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x05, 0x6f, 0x6e, 0x65, 0x6f, + 0x66, 0x3a, 0x54, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x87, 0x09, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, + 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, + 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x63, 0x0a, 0x0a, 0x70, 0x72, 0x65, 0x64, 0x65, + 0x66, 0x69, 0x6e, 0x65, 0x64, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x88, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x62, 0x75, + 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x50, 0x72, 0x65, 0x64, 0x65, + 0x66, 0x69, 0x6e, 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, + 0x52, 0x0a, 0x70, 0x72, 0x65, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x42, 0xb5, 0x01, 0x0a, + 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x65, 0x42, 0x0d, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, + 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x65, 0xa2, 0x02, 0x03, 0x42, 0x56, 0x58, 0xaa, 0x02, 0x0c, 0x42, 0x75, + 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0xca, 0x02, 0x0c, 0x42, 0x75, 0x66, + 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0xe2, 0x02, 0x18, 0x42, 0x75, 0x66, 0x5c, + 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0d, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x56, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x65, } var ( @@ -10292,43 +10654,46 @@ func file_buf_validate_validate_proto_rawDescGZIP() []byte { } var file_buf_validate_validate_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_buf_validate_validate_proto_msgTypes = make([]protoimpl.MessageInfo, 28) +var file_buf_validate_validate_proto_msgTypes = make([]protoimpl.MessageInfo, 30) var file_buf_validate_validate_proto_goTypes = []any{ - (Ignore)(0), // 0: buf.validate.Ignore - (KnownRegex)(0), // 1: buf.validate.KnownRegex - (*Constraint)(nil), // 2: buf.validate.Constraint - (*MessageConstraints)(nil), // 3: buf.validate.MessageConstraints - (*OneofConstraints)(nil), // 4: buf.validate.OneofConstraints - (*FieldConstraints)(nil), // 5: buf.validate.FieldConstraints - (*PredefinedConstraints)(nil), // 6: buf.validate.PredefinedConstraints - (*FloatRules)(nil), // 7: buf.validate.FloatRules - (*DoubleRules)(nil), // 8: buf.validate.DoubleRules - (*Int32Rules)(nil), // 9: buf.validate.Int32Rules - (*Int64Rules)(nil), // 10: buf.validate.Int64Rules - (*UInt32Rules)(nil), // 11: buf.validate.UInt32Rules - (*UInt64Rules)(nil), // 12: buf.validate.UInt64Rules - (*SInt32Rules)(nil), // 13: buf.validate.SInt32Rules - (*SInt64Rules)(nil), // 14: buf.validate.SInt64Rules - (*Fixed32Rules)(nil), // 15: buf.validate.Fixed32Rules - (*Fixed64Rules)(nil), // 16: buf.validate.Fixed64Rules - (*SFixed32Rules)(nil), // 17: buf.validate.SFixed32Rules - (*SFixed64Rules)(nil), // 18: buf.validate.SFixed64Rules - (*BoolRules)(nil), // 19: buf.validate.BoolRules - (*StringRules)(nil), // 20: buf.validate.StringRules - (*BytesRules)(nil), // 21: buf.validate.BytesRules - (*EnumRules)(nil), // 22: buf.validate.EnumRules - (*RepeatedRules)(nil), // 23: buf.validate.RepeatedRules - (*MapRules)(nil), // 24: buf.validate.MapRules - (*AnyRules)(nil), // 25: buf.validate.AnyRules - (*DurationRules)(nil), // 26: buf.validate.DurationRules - (*TimestampRules)(nil), // 27: buf.validate.TimestampRules - (*Violations)(nil), // 28: buf.validate.Violations - (*Violation)(nil), // 29: buf.validate.Violation - (*durationpb.Duration)(nil), // 30: google.protobuf.Duration - (*timestamppb.Timestamp)(nil), // 31: google.protobuf.Timestamp - (*descriptorpb.MessageOptions)(nil), // 32: google.protobuf.MessageOptions - (*descriptorpb.OneofOptions)(nil), // 33: google.protobuf.OneofOptions - (*descriptorpb.FieldOptions)(nil), // 34: google.protobuf.FieldOptions + (Ignore)(0), // 0: buf.validate.Ignore + (KnownRegex)(0), // 1: buf.validate.KnownRegex + (*Constraint)(nil), // 2: buf.validate.Constraint + (*MessageConstraints)(nil), // 3: buf.validate.MessageConstraints + (*OneofConstraints)(nil), // 4: buf.validate.OneofConstraints + (*FieldConstraints)(nil), // 5: buf.validate.FieldConstraints + (*PredefinedConstraints)(nil), // 6: buf.validate.PredefinedConstraints + (*FloatRules)(nil), // 7: buf.validate.FloatRules + (*DoubleRules)(nil), // 8: buf.validate.DoubleRules + (*Int32Rules)(nil), // 9: buf.validate.Int32Rules + (*Int64Rules)(nil), // 10: buf.validate.Int64Rules + (*UInt32Rules)(nil), // 11: buf.validate.UInt32Rules + (*UInt64Rules)(nil), // 12: buf.validate.UInt64Rules + (*SInt32Rules)(nil), // 13: buf.validate.SInt32Rules + (*SInt64Rules)(nil), // 14: buf.validate.SInt64Rules + (*Fixed32Rules)(nil), // 15: buf.validate.Fixed32Rules + (*Fixed64Rules)(nil), // 16: buf.validate.Fixed64Rules + (*SFixed32Rules)(nil), // 17: buf.validate.SFixed32Rules + (*SFixed64Rules)(nil), // 18: buf.validate.SFixed64Rules + (*BoolRules)(nil), // 19: buf.validate.BoolRules + (*StringRules)(nil), // 20: buf.validate.StringRules + (*BytesRules)(nil), // 21: buf.validate.BytesRules + (*EnumRules)(nil), // 22: buf.validate.EnumRules + (*RepeatedRules)(nil), // 23: buf.validate.RepeatedRules + (*MapRules)(nil), // 24: buf.validate.MapRules + (*AnyRules)(nil), // 25: buf.validate.AnyRules + (*DurationRules)(nil), // 26: buf.validate.DurationRules + (*TimestampRules)(nil), // 27: buf.validate.TimestampRules + (*Violations)(nil), // 28: buf.validate.Violations + (*Violation)(nil), // 29: buf.validate.Violation + (*FieldPath)(nil), // 30: buf.validate.FieldPath + (*FieldPathElement)(nil), // 31: buf.validate.FieldPathElement + (*durationpb.Duration)(nil), // 32: google.protobuf.Duration + (*timestamppb.Timestamp)(nil), // 33: google.protobuf.Timestamp + (descriptorpb.FieldDescriptorProto_Type)(0), // 34: google.protobuf.FieldDescriptorProto.Type + (*descriptorpb.MessageOptions)(nil), // 35: google.protobuf.MessageOptions + (*descriptorpb.OneofOptions)(nil), // 36: google.protobuf.OneofOptions + (*descriptorpb.FieldOptions)(nil), // 37: google.protobuf.FieldOptions } var file_buf_validate_validate_proto_depIdxs = []int32{ 2, // 0: buf.validate.MessageConstraints.cel:type_name -> buf.validate.Constraint @@ -10360,35 +10725,41 @@ var file_buf_validate_validate_proto_depIdxs = []int32{ 5, // 26: buf.validate.RepeatedRules.items:type_name -> buf.validate.FieldConstraints 5, // 27: buf.validate.MapRules.keys:type_name -> buf.validate.FieldConstraints 5, // 28: buf.validate.MapRules.values:type_name -> buf.validate.FieldConstraints - 30, // 29: buf.validate.DurationRules.const:type_name -> google.protobuf.Duration - 30, // 30: buf.validate.DurationRules.lt:type_name -> google.protobuf.Duration - 30, // 31: buf.validate.DurationRules.lte:type_name -> google.protobuf.Duration - 30, // 32: buf.validate.DurationRules.gt:type_name -> google.protobuf.Duration - 30, // 33: buf.validate.DurationRules.gte:type_name -> google.protobuf.Duration - 30, // 34: buf.validate.DurationRules.in:type_name -> google.protobuf.Duration - 30, // 35: buf.validate.DurationRules.not_in:type_name -> google.protobuf.Duration - 30, // 36: buf.validate.DurationRules.example:type_name -> google.protobuf.Duration - 31, // 37: buf.validate.TimestampRules.const:type_name -> google.protobuf.Timestamp - 31, // 38: buf.validate.TimestampRules.lt:type_name -> google.protobuf.Timestamp - 31, // 39: buf.validate.TimestampRules.lte:type_name -> google.protobuf.Timestamp - 31, // 40: buf.validate.TimestampRules.gt:type_name -> google.protobuf.Timestamp - 31, // 41: buf.validate.TimestampRules.gte:type_name -> google.protobuf.Timestamp - 30, // 42: buf.validate.TimestampRules.within:type_name -> google.protobuf.Duration - 31, // 43: buf.validate.TimestampRules.example:type_name -> google.protobuf.Timestamp + 32, // 29: buf.validate.DurationRules.const:type_name -> google.protobuf.Duration + 32, // 30: buf.validate.DurationRules.lt:type_name -> google.protobuf.Duration + 32, // 31: buf.validate.DurationRules.lte:type_name -> google.protobuf.Duration + 32, // 32: buf.validate.DurationRules.gt:type_name -> google.protobuf.Duration + 32, // 33: buf.validate.DurationRules.gte:type_name -> google.protobuf.Duration + 32, // 34: buf.validate.DurationRules.in:type_name -> google.protobuf.Duration + 32, // 35: buf.validate.DurationRules.not_in:type_name -> google.protobuf.Duration + 32, // 36: buf.validate.DurationRules.example:type_name -> google.protobuf.Duration + 33, // 37: buf.validate.TimestampRules.const:type_name -> google.protobuf.Timestamp + 33, // 38: buf.validate.TimestampRules.lt:type_name -> google.protobuf.Timestamp + 33, // 39: buf.validate.TimestampRules.lte:type_name -> google.protobuf.Timestamp + 33, // 40: buf.validate.TimestampRules.gt:type_name -> google.protobuf.Timestamp + 33, // 41: buf.validate.TimestampRules.gte:type_name -> google.protobuf.Timestamp + 32, // 42: buf.validate.TimestampRules.within:type_name -> google.protobuf.Duration + 33, // 43: buf.validate.TimestampRules.example:type_name -> google.protobuf.Timestamp 29, // 44: buf.validate.Violations.violations:type_name -> buf.validate.Violation - 32, // 45: buf.validate.message:extendee -> google.protobuf.MessageOptions - 33, // 46: buf.validate.oneof:extendee -> google.protobuf.OneofOptions - 34, // 47: buf.validate.field:extendee -> google.protobuf.FieldOptions - 34, // 48: buf.validate.predefined:extendee -> google.protobuf.FieldOptions - 3, // 49: buf.validate.message:type_name -> buf.validate.MessageConstraints - 4, // 50: buf.validate.oneof:type_name -> buf.validate.OneofConstraints - 5, // 51: buf.validate.field:type_name -> buf.validate.FieldConstraints - 6, // 52: buf.validate.predefined:type_name -> buf.validate.PredefinedConstraints - 53, // [53:53] is the sub-list for method output_type - 53, // [53:53] is the sub-list for method input_type - 49, // [49:53] is the sub-list for extension type_name - 45, // [45:49] is the sub-list for extension extendee - 0, // [0:45] is the sub-list for field type_name + 30, // 45: buf.validate.Violation.field:type_name -> buf.validate.FieldPath + 30, // 46: buf.validate.Violation.rule:type_name -> buf.validate.FieldPath + 31, // 47: buf.validate.FieldPath.elements:type_name -> buf.validate.FieldPathElement + 34, // 48: buf.validate.FieldPathElement.field_type:type_name -> google.protobuf.FieldDescriptorProto.Type + 34, // 49: buf.validate.FieldPathElement.key_type:type_name -> google.protobuf.FieldDescriptorProto.Type + 34, // 50: buf.validate.FieldPathElement.value_type:type_name -> google.protobuf.FieldDescriptorProto.Type + 35, // 51: buf.validate.message:extendee -> google.protobuf.MessageOptions + 36, // 52: buf.validate.oneof:extendee -> google.protobuf.OneofOptions + 37, // 53: buf.validate.field:extendee -> google.protobuf.FieldOptions + 37, // 54: buf.validate.predefined:extendee -> google.protobuf.FieldOptions + 3, // 55: buf.validate.message:type_name -> buf.validate.MessageConstraints + 4, // 56: buf.validate.oneof:type_name -> buf.validate.OneofConstraints + 5, // 57: buf.validate.field:type_name -> buf.validate.FieldConstraints + 6, // 58: buf.validate.predefined:type_name -> buf.validate.PredefinedConstraints + 59, // [59:59] is the sub-list for method output_type + 59, // [59:59] is the sub-list for method input_type + 55, // [55:59] is the sub-list for extension type_name + 51, // [51:55] is the sub-list for extension extendee + 0, // [0:51] is the sub-list for field type_name } func init() { file_buf_validate_validate_proto_init() } @@ -10773,6 +11144,30 @@ func file_buf_validate_validate_proto_init() { return nil } } + file_buf_validate_validate_proto_msgTypes[28].Exporter = func(v any, i int) any { + switch v := v.(*FieldPath); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_validate_proto_msgTypes[29].Exporter = func(v any, i int) any { + switch v := v.(*FieldPathElement); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_buf_validate_validate_proto_msgTypes[3].OneofWrappers = []any{ (*FieldConstraints_Float)(nil), @@ -10908,13 +11303,20 @@ func file_buf_validate_validate_proto_init() { (*TimestampRules_Gte)(nil), (*TimestampRules_GtNow)(nil), } + file_buf_validate_validate_proto_msgTypes[29].OneofWrappers = []any{ + (*FieldPathElement_Index)(nil), + (*FieldPathElement_BoolKey)(nil), + (*FieldPathElement_IntKey)(nil), + (*FieldPathElement_UintKey)(nil), + (*FieldPathElement_StringKey)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_buf_validate_validate_proto_rawDesc, NumEnums: 2, - NumMessages: 28, + NumMessages: 30, NumExtensions: 4, NumServices: 0, }, diff --git a/tools/protovalidate-conformance/internal/cases/cases_any.go b/tools/protovalidate-conformance/internal/cases/cases_any.go index 68ba8ec2..57f31c3c 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_any.go +++ b/tools/protovalidate-conformance/internal/cases/cases_any.go @@ -60,12 +60,22 @@ func anySuite() suites.Suite { "in/invalid/known": { Message: &cases.AnyIn{Val: tsAny}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("any.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("any.in"), + ConstraintId: proto.String("any.in"), + }, + ), }, "in/invalid/unknown": { Message: &cases.AnyIn{Val: fooAny}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("any.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("any.in"), + ConstraintId: proto.String("any.in"), + }, + ), }, "not_in/valid/known": { Message: &cases.AnyNotIn{Val: durAny}, @@ -82,7 +92,12 @@ func anySuite() suites.Suite { "not_in/invalid/known": { Message: &cases.AnyNotIn{Val: tsAny}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("any.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("any.not_in"), + ConstraintId: proto.String("any.not_in"), + }, + ), }, "required/valid/known": { Message: &cases.AnyRequired{Val: tsAny}, @@ -95,7 +110,12 @@ func anySuite() suites.Suite { "require/invalid": { Message: &cases.AnyRequired{}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }, + ), }, } } diff --git a/tools/protovalidate-conformance/internal/cases/cases_bool.go b/tools/protovalidate-conformance/internal/cases/cases_bool.go index e7b85890..d4f875a3 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_bool.go +++ b/tools/protovalidate-conformance/internal/cases/cases_bool.go @@ -35,7 +35,12 @@ func boolSuite() suites.Suite { "const/true/invalid": { Message: &cases.BoolConstTrue{Val: false}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("bool.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("bool.const"), + ConstraintId: proto.String("bool.const"), + }, + ), }, "const/false/valid": { Message: &cases.BoolConstFalse{Val: false}, @@ -44,7 +49,12 @@ func boolSuite() suites.Suite { "const/false/invalid": { Message: &cases.BoolConstFalse{Val: true}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("bool.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("bool.const"), + ConstraintId: proto.String("bool.const"), + }, + ), }, "example/valid": { Message: &cases.BoolExample{Val: true}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_bytes.go b/tools/protovalidate-conformance/internal/cases/cases_bytes.go index 8d40e541..81ba93c0 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_bytes.go +++ b/tools/protovalidate-conformance/internal/cases/cases_bytes.go @@ -35,7 +35,12 @@ func bytesSuite() suites.Suite { "const/invalid": { Message: &cases.BytesConst{Val: []byte("bar")}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("bytes.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.const"), + ConstraintId: proto.String("bytes.const"), + }, + ), }, "in/valid": { Message: &cases.BytesIn{Val: []byte("bar")}, @@ -44,7 +49,12 @@ func bytesSuite() suites.Suite { "in/invalid": { Message: &cases.BytesIn{Val: []byte("quux")}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("bytes.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.in"), + ConstraintId: proto.String("bytes.in"), + }, + ), }, "not_in/valid": { Message: &cases.BytesNotIn{Val: []byte("quux")}, @@ -53,7 +63,12 @@ func bytesSuite() suites.Suite { "not_in/invalid": { Message: &cases.BytesNotIn{Val: []byte("fizz")}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("bytes.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.not_in"), + ConstraintId: proto.String("bytes.not_in"), + }, + ), }, "len/valid": { Message: &cases.BytesLen{Val: []byte("baz")}, @@ -62,12 +77,22 @@ func bytesSuite() suites.Suite { "len/invalid/less": { Message: &cases.BytesLen{Val: []byte("go")}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("bytes.len")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.len"), + ConstraintId: proto.String("bytes.len"), + }, + ), }, "len/invalid/greater": { Message: &cases.BytesLen{Val: []byte("fizz")}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("bytes.len")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.len"), + ConstraintId: proto.String("bytes.len"), + }, + ), }, "min_len/valid/equal": { Message: &cases.BytesMinLen{Val: []byte("baz")}, @@ -80,7 +105,8 @@ func bytesSuite() suites.Suite { "min_len/invalid": { Message: &cases.BytesMinLen{Val: []byte("go")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.min_len"), ConstraintId: proto.String("bytes.min_len"), Message: proto.String("value length must be at least 3 bytes"), }), @@ -96,7 +122,8 @@ func bytesSuite() suites.Suite { "max_len/invalid": { Message: &cases.BytesMaxLen{Val: []byte("1234567890")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.max_len"), ConstraintId: proto.String("bytes.max_len"), Message: proto.String("value must be at most 5 bytes"), }), @@ -116,7 +143,8 @@ func bytesSuite() suites.Suite { "min/max_len/invalid/below": { Message: &cases.BytesMinMaxLen{Val: []byte("go")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.min_len"), ConstraintId: proto.String("bytes.min_len"), Message: proto.String("value length must be at least 3 bytes"), }), @@ -124,7 +152,8 @@ func bytesSuite() suites.Suite { "min/max_len/invalid/above": { Message: &cases.BytesMinMaxLen{Val: []byte("validate")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.max_len"), ConstraintId: proto.String("bytes.max_len"), Message: proto.String("value must be at most 5 bytes"), }), @@ -136,7 +165,8 @@ func bytesSuite() suites.Suite { "equal/min_len/max_len/invalid": { Message: &cases.BytesEqualMinMaxLen{Val: []byte("validate")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.max_len"), ConstraintId: proto.String("bytes.max_len"), Message: proto.String("value must be at most 5 bytes"), }), @@ -148,7 +178,8 @@ func bytesSuite() suites.Suite { "pattern/invalid": { Message: &cases.BytesPattern{Val: []byte("你好你好")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.pattern"), ConstraintId: proto.String("bytes.pattern"), Message: proto.String("value must match regex pattern `^[\\x00-\\x7F]+$`"), }), @@ -156,7 +187,8 @@ func bytesSuite() suites.Suite { "pattern/invalid/empty": { Message: &cases.BytesPattern{Val: []byte("")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.pattern"), ConstraintId: proto.String("bytes.pattern"), Message: proto.String("value must match regex pattern `^[\\x00-\\x7F]+$`"), }), @@ -176,7 +208,8 @@ func bytesSuite() suites.Suite { "prefix/invalid": { Message: &cases.BytesPrefix{Val: []byte("bar")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.prefix"), ConstraintId: proto.String("bytes.prefix"), Message: proto.String("value does not have prefix 99"), }), @@ -192,7 +225,8 @@ func bytesSuite() suites.Suite { "contains/invalid": { Message: &cases.BytesContains{Val: []byte("candy bazs")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.contains"), ConstraintId: proto.String("bytes.contains"), Message: proto.String("value does not contain 626172"), }), @@ -208,7 +242,8 @@ func bytesSuite() suites.Suite { "suffix/invalid": { Message: &cases.BytesSuffix{Val: []byte("foobar")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.suffix"), ConstraintId: proto.String("bytes.suffix"), Message: proto.String("value does not have suffix 62757a7a"), }), @@ -216,7 +251,8 @@ func bytesSuite() suites.Suite { "suffix/case_sensitive/invalid": { Message: &cases.BytesSuffix{Val: []byte("FooBaz")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.suffix"), ConstraintId: proto.String("bytes.suffix"), Message: proto.String("value does not have suffix 62757a7a"), }), @@ -232,7 +268,8 @@ func bytesSuite() suites.Suite { "IP/invalid": { Message: &cases.BytesIP{Val: []byte("foobar")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.ip"), ConstraintId: proto.String("bytes.ip"), Message: proto.String("value must be a valid IP address"), }), @@ -248,7 +285,8 @@ func bytesSuite() suites.Suite { "IPv4/invalid": { Message: &cases.BytesIPv4{Val: []byte("foobar")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.ipv4"), ConstraintId: proto.String("bytes.ipv4"), Message: proto.String("value must be a valid IPv4 address"), }), @@ -260,7 +298,8 @@ func bytesSuite() suites.Suite { "IPv4/invalid/v6": { Message: &cases.BytesIPv4{Val: []byte("\x20\x01\x0D\xB8\x85\xA3\x00\x00\x00\x00\x8A\x2E\x03\x70\x73\x34")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.ipv4"), ConstraintId: proto.String("bytes.ipv4"), Message: proto.String("value must be a valid IPv4 address"), }), @@ -272,7 +311,8 @@ func bytesSuite() suites.Suite { "IPv6/invalid": { Message: &cases.BytesIPv6{Val: []byte("fooar")}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.ipv6"), ConstraintId: proto.String("bytes.ipv6"), Message: proto.String("value must be a valid IPv6 address"), }), @@ -284,7 +324,8 @@ func bytesSuite() suites.Suite { "IPv6/invalid/v4": { Message: &cases.BytesIPv6{Val: []byte{0xC0, 0xA8, 0x00, 0x01}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.ipv6"), ConstraintId: proto.String("bytes.ipv6"), }), }, diff --git a/tools/protovalidate-conformance/internal/cases/cases_custom_constraints.go b/tools/protovalidate-conformance/internal/cases/cases_custom_constraints.go index da5cc959..07381618 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_custom_constraints.go +++ b/tools/protovalidate-conformance/internal/cases/cases_custom_constraints.go @@ -80,11 +80,11 @@ func customSuite() suites.Suite { &validate.Violation{ConstraintId: proto.String("message_expression_enum")}, &validate.Violation{ConstraintId: proto.String("message_expression_embed")}, &validate.Violation{ - FieldPath: proto.String("e"), + Field: results.FieldPath("e"), ConstraintId: proto.String("message_expression_nested"), }, &validate.Violation{ - FieldPath: proto.String("f"), + Field: results.FieldPath("f"), ConstraintId: proto.String("message_expression_nested"), }, ), @@ -93,11 +93,13 @@ func customSuite() suites.Suite { Message: &custom_constraints.FieldExpressions{}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("field_expression_scalar"), }, &validate.Violation{ - FieldPath: proto.String("b"), + Field: results.FieldPath("b"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("field_expression_enum"), }, ), @@ -109,6 +111,7 @@ func customSuite() suites.Suite { C: &custom_constraints.FieldExpressions_Nested{ A: 16, }, + D: 0, }, Expected: results.Success(true), }, @@ -119,24 +122,39 @@ func customSuite() suites.Suite { C: &custom_constraints.FieldExpressions_Nested{ A: -3, }, + D: 3, }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("field_expression_scalar"), }, &validate.Violation{ - FieldPath: proto.String("b"), + Field: results.FieldPath("b"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("field_expression_enum"), }, &validate.Violation{ - FieldPath: proto.String("c"), + Field: results.FieldPath("c"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("field_expression_embed"), }, &validate.Violation{ - FieldPath: proto.String("c.a"), + Field: results.FieldPath("c.a"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("field_expression_nested"), }, + &validate.Violation{ + Field: results.FieldPath("d"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("field_expression_scalar_multiple_1"), + }, + &validate.Violation{ + Field: results.FieldPath("d"), + Rule: results.FieldPath("cel[1]"), + ConstraintId: proto.String("field_expression_scalar_multiple_2"), + }, ), }, "now/equality": { diff --git a/tools/protovalidate-conformance/internal/cases/cases_double.go b/tools/protovalidate-conformance/internal/cases/cases_double.go index 1befedce..eb2ef61e 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_double.go +++ b/tools/protovalidate-conformance/internal/cases/cases_double.go @@ -37,12 +37,22 @@ func doubleSuite() suites.Suite { "const/invalid": { Message: &cases.DoubleConst{Val: 4.56}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.const"), + ConstraintId: proto.String("double.const"), + }, + ), }, "const/invalid_nan": { Message: &cases.DoubleConst{Val: math.NaN()}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.const"), + ConstraintId: proto.String("double.const"), + }, + ), }, "in/valid": { Message: &cases.DoubleIn{Val: 7.89}, @@ -51,12 +61,22 @@ func doubleSuite() suites.Suite { "in/invalid": { Message: &cases.DoubleIn{Val: 10.11}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.in"), + ConstraintId: proto.String("double.in"), + }, + ), }, "in/invalid_nan": { Message: &cases.DoubleIn{Val: math.NaN()}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.in"), + ConstraintId: proto.String("double.in"), + }, + ), }, "not_in/valid": { Message: &cases.DoubleNotIn{Val: 1}, @@ -69,7 +89,12 @@ func doubleSuite() suites.Suite { "not_in/invalid": { Message: &cases.DoubleNotIn{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.not_in"), + ConstraintId: proto.String("double.not_in"), + }, + ), }, "lt/valid/less": { Message: &cases.DoubleLT{Val: -1}, @@ -78,17 +103,32 @@ func doubleSuite() suites.Suite { "lt/invalid/equal": { Message: &cases.DoubleLT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.lt"), + ConstraintId: proto.String("double.lt"), + }, + ), }, "lt/invalid/greater": { Message: &cases.DoubleLT{Val: 1}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.lt"), + ConstraintId: proto.String("double.lt"), + }, + ), }, "lt/invalid/nan": { Message: &cases.DoubleLT{Val: math.NaN()}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.lt"), + ConstraintId: proto.String("double.lt"), + }, + ), }, "lte/valid/less": { Message: &cases.DoubleLTE{Val: 63}, @@ -101,12 +141,22 @@ func doubleSuite() suites.Suite { "lte/invalid/greater": { Message: &cases.DoubleLTE{Val: 65}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.lte"), + ConstraintId: proto.String("double.lte"), + }, + ), }, "lte/invalid/nan": { Message: &cases.DoubleLTE{Val: math.NaN()}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.lte"), + ConstraintId: proto.String("double.lte"), + }, + ), }, "gt/valid/greater": { Message: &cases.DoubleGT{Val: 17}, @@ -115,17 +165,32 @@ func doubleSuite() suites.Suite { "gt/invalid/equal": { Message: &cases.DoubleGT{Val: 16}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gt"), + ConstraintId: proto.String("double.gt"), + }, + ), }, "gt/invalid/less": { Message: &cases.DoubleGT{Val: 15}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gt"), + ConstraintId: proto.String("double.gt"), + }, + ), }, "gt/invalid/nan": { Message: &cases.DoubleGT{Val: math.NaN()}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gt"), + ConstraintId: proto.String("double.gt"), + }, + ), }, "gte/valid/greater": { Message: &cases.DoubleGTE{Val: 9}, @@ -138,12 +203,22 @@ func doubleSuite() suites.Suite { "gte/invalid/less": { Message: &cases.DoubleGTE{Val: 7}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gte"), + ConstraintId: proto.String("double.gte"), + }, + ), }, "gte/invalid/nan": { Message: &cases.DoubleGTE{Val: math.NaN()}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gte"), + ConstraintId: proto.String("double.gte"), + }, + ), }, "gt_lt/inclusive/valid/within": { Message: &cases.DoubleGTLT{Val: 5}, @@ -152,22 +227,42 @@ func doubleSuite() suites.Suite { "gt_lt/inclusive/invalid/above": { Message: &cases.DoubleGTLT{Val: 11}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gt"), + ConstraintId: proto.String("double.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/below": { Message: &cases.DoubleGTLT{Val: -1}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gt"), + ConstraintId: proto.String("double.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/max": { Message: &cases.DoubleGTLT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gt"), + ConstraintId: proto.String("double.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/min": { Message: &cases.DoubleGTLT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gt"), + ConstraintId: proto.String("double.gt_lt"), + }, + ), }, "gt_lt/exclusive/valid/above": { Message: &cases.DoubleExLTGT{Val: 11}, @@ -180,22 +275,42 @@ func doubleSuite() suites.Suite { "gt_lt/exclusive/invalid/within": { Message: &cases.DoubleExLTGT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gt"), + ConstraintId: proto.String("double.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/max": { Message: &cases.DoubleExLTGT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gt"), + ConstraintId: proto.String("double.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/min": { Message: &cases.DoubleExLTGT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gt"), + ConstraintId: proto.String("double.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/nan": { Message: &cases.DoubleExLTGT{Val: math.NaN()}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gt"), + ConstraintId: proto.String("double.gt_lt_exclusive"), + }, + ), }, "gte_lte/inclusive/valid/within": { Message: &cases.DoubleGTELTE{Val: 200}, @@ -212,17 +327,32 @@ func doubleSuite() suites.Suite { "gte_lte/inclusive/invalid/above": { Message: &cases.DoubleGTELTE{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gte"), + ConstraintId: proto.String("double.gte_lte"), + }, + ), }, "gte_lte/inclusive/invalid/below": { Message: &cases.DoubleGTELTE{Val: 100}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gte"), + ConstraintId: proto.String("double.gte_lte"), + }, + ), }, "gte_lte/inclusive/invalid/nan": { Message: &cases.DoubleGTELTE{Val: math.NaN()}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gte"), + ConstraintId: proto.String("double.gte_lte"), + }, + ), }, "gte_lte/exclusive/valid/above": { Message: &cases.DoubleExGTELTE{Val: 300}, @@ -243,12 +373,22 @@ func doubleSuite() suites.Suite { "gte_lte/exclusive/invalid/within": { Message: &cases.DoubleExGTELTE{Val: 200}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gte_lte_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gte"), + ConstraintId: proto.String("double.gte_lte_exclusive"), + }, + ), }, "gte_lte/exclusive/invalid/nan": { Message: &cases.DoubleExGTELTE{Val: math.NaN()}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gte_lte_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gte"), + ConstraintId: proto.String("double.gte_lte_exclusive"), + }, + ), }, "finite/valid": { Message: &cases.DoubleFinite{Val: 1}, @@ -258,7 +398,8 @@ func doubleSuite() suites.Suite { Message: &cases.DoubleFinite{Val: math.NaN()}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.finite"), ConstraintId: proto.String("double.finite"), Message: proto.String("value must be finite"), }), @@ -267,7 +408,8 @@ func doubleSuite() suites.Suite { Message: &cases.DoubleFinite{Val: math.Inf(1)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.finite"), ConstraintId: proto.String("double.finite"), Message: proto.String("value must be finite")}), }, @@ -279,9 +421,12 @@ func doubleSuite() suites.Suite { Message: &cases.DoubleFinite{Val: math.Inf(-1)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.finite"), ConstraintId: proto.String("double.finite"), - Message: proto.String("value must be finite")}), + Message: proto.String("value must be finite"), + }, + ), }, "ignore_empty/valid/empty": { Message: &cases.DoubleIgnore{Val: 0}, @@ -294,7 +439,7 @@ func doubleSuite() suites.Suite { "ignore_empty/invalid/above": { Message: &cases.DoubleIgnore{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("double.gte_lte")}), + &validate.Violation{Field: results.FieldPath("val"), Rule: results.FieldPath("double.gte"), ConstraintId: proto.String("double.gte_lte")}), }, "compilation/wrong_type": { Message: &cases.DoubleIncorrectType{Val: 123}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_duration.go b/tools/protovalidate-conformance/internal/cases/cases_duration.go index e7688973..d6bd8594 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_duration.go +++ b/tools/protovalidate-conformance/internal/cases/cases_duration.go @@ -44,7 +44,8 @@ func durationSuite() suites.Suite { Val: nil, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), ConstraintId: proto.String("required"), Message: proto.String("value is required"), }), @@ -67,7 +68,8 @@ func durationSuite() suites.Suite { }, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.const"), ConstraintId: proto.String("duration.const"), Message: proto.String("value must equal 3s"), }), @@ -88,7 +90,8 @@ func durationSuite() suites.Suite { Val: &durationpb.Duration{}, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.in"), ConstraintId: proto.String("duration.in"), Message: proto.String(`value must be in list [duration("1s"), duration("0.000001s")]`), }), @@ -109,7 +112,8 @@ func durationSuite() suites.Suite { Val: &durationpb.Duration{}, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.not_in"), ConstraintId: proto.String("duration.not_in"), Message: proto.String(`value must not be in list [duration("0s")]`), }), @@ -130,7 +134,8 @@ func durationSuite() suites.Suite { Val: &durationpb.Duration{}, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.lt"), ConstraintId: proto.String("duration.lt"), Message: proto.String("value must be less than 0s"), }), @@ -142,7 +147,8 @@ func durationSuite() suites.Suite { }, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.lt"), ConstraintId: proto.String("duration.lt"), Message: proto.String("value must be less than 0s"), }), @@ -171,7 +177,8 @@ func durationSuite() suites.Suite { }, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.lte"), ConstraintId: proto.String("duration.lte"), Message: proto.String(""), }), @@ -194,7 +201,8 @@ func durationSuite() suites.Suite { }, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.gt"), ConstraintId: proto.String("duration.gt"), Message: proto.String(""), }), @@ -204,7 +212,8 @@ func durationSuite() suites.Suite { Val: &durationpb.Duration{}, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.gt"), ConstraintId: proto.String("duration.gt"), Message: proto.String("value must be greater than 0.000001s"), }), @@ -233,7 +242,8 @@ func durationSuite() suites.Suite { Val: &durationpb.Duration{Seconds: -1}, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.gte"), ConstraintId: proto.String("duration.gte"), Message: proto.String("value must be greater than or equal to 0.001s"), }), @@ -256,7 +266,8 @@ func durationSuite() suites.Suite { }, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.gt"), ConstraintId: proto.String("duration.gt_lt"), Message: proto.String("value must be greater than 0s and less than 1s"), }), @@ -267,7 +278,8 @@ func durationSuite() suites.Suite { Nanos: -1000, }, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.gt"), ConstraintId: proto.String("duration.gt_lt"), Message: proto.String("value must be greater than 0s and less than 1s"), }), @@ -279,7 +291,8 @@ func durationSuite() suites.Suite { }, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.gt"), ConstraintId: proto.String("duration.gt_lt"), Message: proto.String("value must be greater than 0s and less than 1s"), }), @@ -289,7 +302,8 @@ func durationSuite() suites.Suite { Val: &durationpb.Duration{}, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.gt"), ConstraintId: proto.String("duration.gt_lt"), Message: proto.String("value must be greater than 0s and less than 1s"), }), @@ -320,7 +334,8 @@ func durationSuite() suites.Suite { }, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.gt"), ConstraintId: proto.String("duration.gt_lt_exclusive"), Message: proto.String("value must be greater than 1s or less than 0s"), }), @@ -332,7 +347,8 @@ func durationSuite() suites.Suite { }, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.gt"), ConstraintId: proto.String("duration.gt_lt_exclusive"), Message: proto.String("value must be greater than 1s or less than 0s"), }), @@ -342,7 +358,8 @@ func durationSuite() suites.Suite { Val: &durationpb.Duration{}, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.gt"), ConstraintId: proto.String("duration.gt_lt_exclusive"), Message: proto.String("value must be greater than 1s or less than 0s"), }), @@ -378,7 +395,8 @@ func durationSuite() suites.Suite { Val: &durationpb.Duration{Seconds: 3600, Nanos: 1}, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.gte"), ConstraintId: proto.String("duration.gte_lte"), Message: proto.String("value must be greater than or equal to 60s and less than or equal to 3600s"), }), @@ -390,7 +408,8 @@ func durationSuite() suites.Suite { }, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.gte"), ConstraintId: proto.String("duration.gte_lte"), Message: proto.String("value must be greater than or equal to 60s and less than or equal to 3600s"), }), @@ -433,7 +452,8 @@ func durationSuite() suites.Suite { }, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.gte"), ConstraintId: proto.String("duration.gte_lte_exclusive"), Message: proto.String("value must be greater than or equal to 3600s or less than or equal to 60s"), }), @@ -441,7 +461,8 @@ func durationSuite() suites.Suite { "fields_with_other_fields/invalid_other_field": { Message: &cases.DurationFieldWithOtherFields{DurationVal: nil, IntVal: 12}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("int_val"), + Field: results.FieldPath("int_val"), + Rule: results.FieldPath("int32.gt"), ConstraintId: proto.String("int32.gt"), Message: proto.String("value must be greater than 16"), }), diff --git a/tools/protovalidate-conformance/internal/cases/cases_enum.go b/tools/protovalidate-conformance/internal/cases/cases_enum.go index 3c6082fa..4e6b9da8 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_enum.go +++ b/tools/protovalidate-conformance/internal/cases/cases_enum.go @@ -38,7 +38,12 @@ func enumSuite() suites.Suite { "const/invalid": { Message: &cases.EnumConst{Val: cases.TestEnum_TEST_ENUM_ONE}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("enum.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("enum.const"), + ConstraintId: proto.String("enum.const"), + }, + ), }, "alias/const/valid": { Message: &cases.EnumAliasConst{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_B}, @@ -47,7 +52,12 @@ func enumSuite() suites.Suite { "alias/const/invalid": { Message: &cases.EnumAliasConst{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_GAMMA}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("enum.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("enum.const"), + ConstraintId: proto.String("enum.const"), + }, + ), }, "defined_only/valid/unspecified": { Message: &cases.EnumDefined{Val: cases.TestEnum_TEST_ENUM_UNSPECIFIED}, @@ -60,7 +70,13 @@ func enumSuite() suites.Suite { "defined_only/invalid/unknown": { Message: &cases.EnumDefined{Val: math.MaxInt32}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("enum.defined_only"), Message: proto.String("value must be one of the defined enum values")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("enum.defined_only"), + ConstraintId: proto.String("enum.defined_only"), + Message: proto.String("value must be one of the defined enum values"), + }, + ), }, "alias/defined_only/valid/unspecified": { Message: &cases.EnumAliasDefined{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_UNSPECIFIED}, @@ -73,7 +89,12 @@ func enumSuite() suites.Suite { "alias/defined_only/invalid/unknown": { Message: &cases.EnumAliasDefined{Val: math.MaxInt32}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("enum.defined_only")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("enum.defined_only"), + ConstraintId: proto.String("enum.defined_only"), + }, + ), }, "in/valid": { Message: &cases.EnumIn{Val: cases.TestEnum_TEST_ENUM_TWO}, @@ -82,7 +103,12 @@ func enumSuite() suites.Suite { "in/invalid": { Message: &cases.EnumIn{Val: cases.TestEnum_TEST_ENUM_ONE}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("enum.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("enum.in"), + ConstraintId: proto.String("enum.in"), + }, + ), }, "alias/in/valid": { Message: &cases.EnumAliasIn{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_BETA}, @@ -91,7 +117,12 @@ func enumSuite() suites.Suite { "alias/in/invalid": { Message: &cases.EnumAliasIn{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_A}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("enum.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("enum.in"), + ConstraintId: proto.String("enum.in"), + }, + ), }, "not_in/valid": { Message: &cases.EnumNotIn{Val: cases.TestEnum_TEST_ENUM_UNSPECIFIED}, @@ -104,7 +135,12 @@ func enumSuite() suites.Suite { "not_in/invalid": { Message: &cases.EnumNotIn{Val: cases.TestEnum_TEST_ENUM_ONE}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("enum.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("enum.not_in"), + ConstraintId: proto.String("enum.not_in"), + }, + ), }, "alias/not_in/valid": { Message: &cases.EnumAliasNotIn{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_BETA}, @@ -113,7 +149,12 @@ func enumSuite() suites.Suite { "alias/not_in/invalid": { Message: &cases.EnumAliasNotIn{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_A}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("enum.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("enum.not_in"), + ConstraintId: proto.String("enum.not_in"), + }, + ), }, "external/defined_only/valid": { Message: &cases.EnumExternal{Val: other_package.Embed_ENUMERATED_VALUE}, @@ -122,7 +163,12 @@ func enumSuite() suites.Suite { "external/defined_only/invalid": { Message: &cases.EnumExternal{Val: math.MaxInt32}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("enum.defined_only")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("enum.defined_only"), + ConstraintId: proto.String("enum.defined_only"), + }, + ), }, "example/valid": { Message: &cases.EnumExample{Val: cases.TestEnum_TEST_ENUM_TWO}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_fixed32.go b/tools/protovalidate-conformance/internal/cases/cases_fixed32.go index 5c5fe5ff..b785a484 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_fixed32.go +++ b/tools/protovalidate-conformance/internal/cases/cases_fixed32.go @@ -35,7 +35,12 @@ func fixed32Suite() suites.Suite { "const/invalid": { Message: &cases.Fixed32Const{Val: 2}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.const"), + ConstraintId: proto.String("fixed32.const"), + }, + ), }, "in/valid": { Message: &cases.Fixed32In{Val: 3}, @@ -44,7 +49,12 @@ func fixed32Suite() suites.Suite { "in/invalid": { Message: &cases.Fixed32In{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.in"), + ConstraintId: proto.String("fixed32.in"), + }, + ), }, "not_in/valid": { Message: &cases.Fixed32NotIn{Val: 1}, @@ -53,7 +63,12 @@ func fixed32Suite() suites.Suite { "not_in/invalid": { Message: &cases.Fixed32NotIn{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.not_in"), + ConstraintId: proto.String("fixed32.not_in"), + }, + ), }, "lt/valid/less": { Message: &cases.Fixed32LT{Val: 4}, @@ -62,12 +77,22 @@ func fixed32Suite() suites.Suite { "lt/invalid/equal": { Message: &cases.Fixed32LT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.lt"), + ConstraintId: proto.String("fixed32.lt"), + }, + ), }, "lt/invalid/greater": { Message: &cases.Fixed32LT{Val: 6}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.lt"), + ConstraintId: proto.String("fixed32.lt"), + }, + ), }, "lte/valid/less": { Message: &cases.Fixed32LTE{Val: 63}, @@ -80,7 +105,12 @@ func fixed32Suite() suites.Suite { "lte/invalid/greater": { Message: &cases.Fixed32LTE{Val: 65}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.lte"), + ConstraintId: proto.String("fixed32.lte"), + }, + ), }, "gt/valid/greater": { Message: &cases.Fixed32GT{Val: 17}, @@ -89,12 +119,22 @@ func fixed32Suite() suites.Suite { "gt/invalid/equal": { Message: &cases.Fixed32GT{Val: 16}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gt"), + ConstraintId: proto.String("fixed32.gt"), + }, + ), }, "gt/invalid/less": { Message: &cases.Fixed32GT{Val: 15}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gt"), + ConstraintId: proto.String("fixed32.gt"), + }, + ), }, "gte/valid/greater": { Message: &cases.Fixed32GTE{Val: 9}, @@ -107,7 +147,12 @@ func fixed32Suite() suites.Suite { "gte/invalid/less": { Message: &cases.Fixed32GTE{Val: 7}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gte"), + ConstraintId: proto.String("fixed32.gte"), + }, + ), }, "gt_lt/inclusive/valid/within": { Message: &cases.Fixed32GTLT{Val: 6}, @@ -116,22 +161,42 @@ func fixed32Suite() suites.Suite { "gt_lt/inclusive/invalid/above": { Message: &cases.Fixed32GTLT{Val: 11}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gt"), + ConstraintId: proto.String("fixed32.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/below": { Message: &cases.Fixed32GTLT{Val: 4}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gt"), + ConstraintId: proto.String("fixed32.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/max": { Message: &cases.Fixed32GTLT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gt"), + ConstraintId: proto.String("fixed32.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/min": { Message: &cases.Fixed32GTLT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gt"), + ConstraintId: proto.String("fixed32.gt_lt"), + }, + ), }, "gt_lt/exclusive/valid/above": { Message: &cases.Fixed32ExLTGT{Val: 11}, @@ -144,17 +209,32 @@ func fixed32Suite() suites.Suite { "gt_lt/exclusive/invalid/within": { Message: &cases.Fixed32ExLTGT{Val: 6}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gt"), + ConstraintId: proto.String("fixed32.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/max": { Message: &cases.Fixed32ExLTGT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gt"), + ConstraintId: proto.String("fixed32.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/min": { Message: &cases.Fixed32ExLTGT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gt"), + ConstraintId: proto.String("fixed32.gt_lt_exclusive"), + }, + ), }, "gte_lte/inclusive/valid/within": { Message: &cases.Fixed32GTELTE{Val: 200}, @@ -171,12 +251,22 @@ func fixed32Suite() suites.Suite { "gte_lte/inclusive/invalid/above": { Message: &cases.Fixed32GTELTE{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gte"), + ConstraintId: proto.String("fixed32.gte_lte"), + }, + ), }, "gte_lte/inclusive/invalid/below": { Message: &cases.Fixed32GTELTE{Val: 100}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gte"), + ConstraintId: proto.String("fixed32.gte_lte"), + }, + ), }, "gte_lte/exclusive/valid/above": { Message: &cases.Fixed32ExGTELTE{Val: 300}, @@ -197,7 +287,12 @@ func fixed32Suite() suites.Suite { "gte_lte/exclusive/invalid/within": { Message: &cases.Fixed32ExGTELTE{Val: 200}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gte_lte_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gte"), + ConstraintId: proto.String("fixed32.gte_lte_exclusive"), + }, + ), }, "ignore_empty/valid/empty": { Message: &cases.Fixed32Ignore{Val: 0}, @@ -210,7 +305,12 @@ func fixed32Suite() suites.Suite { "ignore_empty/invalid/above": { Message: &cases.Fixed32Ignore{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed32.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.gte"), + ConstraintId: proto.String("fixed32.gte_lte"), + }, + ), }, "compilation/wrong_type": { Message: &cases.Fixed32IncorrectType{Val: 123}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_fixed64.go b/tools/protovalidate-conformance/internal/cases/cases_fixed64.go index 5f411f00..ab94fc85 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_fixed64.go +++ b/tools/protovalidate-conformance/internal/cases/cases_fixed64.go @@ -35,7 +35,12 @@ func fixed64Suite() suites.Suite { "const/invalid": { Message: &cases.Fixed64Const{Val: 2}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.const"), + ConstraintId: proto.String("fixed64.const"), + }, + ), }, "in/valid": { Message: &cases.Fixed64In{Val: 3}, @@ -44,7 +49,12 @@ func fixed64Suite() suites.Suite { "in/invalid": { Message: &cases.Fixed64In{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.in"), + ConstraintId: proto.String("fixed64.in"), + }, + ), }, "not_in/valid": { Message: &cases.Fixed64NotIn{Val: 1}, @@ -53,7 +63,12 @@ func fixed64Suite() suites.Suite { "not_in/invalid": { Message: &cases.Fixed64NotIn{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.not_in"), + ConstraintId: proto.String("fixed64.not_in"), + }, + ), }, "lt/valid/less": { Message: &cases.Fixed64LT{Val: 4}, @@ -62,12 +77,22 @@ func fixed64Suite() suites.Suite { "lt/invalid/equal": { Message: &cases.Fixed64LT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.lt"), + ConstraintId: proto.String("fixed64.lt"), + }, + ), }, "lt/invalid/greater": { Message: &cases.Fixed64LT{Val: 6}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.lt"), + ConstraintId: proto.String("fixed64.lt"), + }, + ), }, "lte/valid/less": { Message: &cases.Fixed64LTE{Val: 63}, @@ -80,7 +105,12 @@ func fixed64Suite() suites.Suite { "lte/invalid/greater": { Message: &cases.Fixed64LTE{Val: 65}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.lte"), + ConstraintId: proto.String("fixed64.lte"), + }, + ), }, "gt/valid/greater": { Message: &cases.Fixed64GT{Val: 17}, @@ -89,12 +119,22 @@ func fixed64Suite() suites.Suite { "gt/invalid/equal": { Message: &cases.Fixed64GT{Val: 16}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gt"), + ConstraintId: proto.String("fixed64.gt"), + }, + ), }, "gt/invalid/less": { Message: &cases.Fixed64GT{Val: 15}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gt"), + ConstraintId: proto.String("fixed64.gt"), + }, + ), }, "gte/valid/greater": { Message: &cases.Fixed64GTE{Val: 9}, @@ -107,7 +147,12 @@ func fixed64Suite() suites.Suite { "gte/invalid/less": { Message: &cases.Fixed64GTE{Val: 7}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gte"), + ConstraintId: proto.String("fixed64.gte"), + }, + ), }, "gt_lt/inclusive/valid/within": { Message: &cases.Fixed64GTLT{Val: 6}, @@ -116,22 +161,42 @@ func fixed64Suite() suites.Suite { "gt_lt/inclusive/invalid/above": { Message: &cases.Fixed64GTLT{Val: 11}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gt"), + ConstraintId: proto.String("fixed64.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/below": { Message: &cases.Fixed64GTLT{Val: 4}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gt"), + ConstraintId: proto.String("fixed64.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/max": { Message: &cases.Fixed64GTLT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gt"), + ConstraintId: proto.String("fixed64.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/min": { Message: &cases.Fixed64GTLT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gt"), + ConstraintId: proto.String("fixed64.gt_lt"), + }, + ), }, "gt_lt/exclusive/valid/above": { Message: &cases.Fixed64ExLTGT{Val: 11}, @@ -144,17 +209,32 @@ func fixed64Suite() suites.Suite { "gt_lt/exclusive/invalid/within": { Message: &cases.Fixed64ExLTGT{Val: 6}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gt"), + ConstraintId: proto.String("fixed64.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/max": { Message: &cases.Fixed64ExLTGT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gt"), + ConstraintId: proto.String("fixed64.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/min": { Message: &cases.Fixed64ExLTGT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gt"), + ConstraintId: proto.String("fixed64.gt_lt_exclusive"), + }, + ), }, "gte_lte/inclusive/valid/within": { Message: &cases.Fixed64GTELTE{Val: 200}, @@ -171,12 +251,22 @@ func fixed64Suite() suites.Suite { "gte_lte/inclusive/invalid/above": { Message: &cases.Fixed64GTELTE{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gte"), + ConstraintId: proto.String("fixed64.gte_lte"), + }, + ), }, "gte_lte/inclusive/invalid/below": { Message: &cases.Fixed64GTELTE{Val: 100}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gte"), + ConstraintId: proto.String("fixed64.gte_lte"), + }, + ), }, "gte_lte/exclusive/valid/above": { Message: &cases.Fixed64ExGTELTE{Val: 300}, @@ -197,7 +287,12 @@ func fixed64Suite() suites.Suite { "gte_lte/exclusive/invalid/within": { Message: &cases.Fixed64ExGTELTE{Val: 200}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gte_lte_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gte"), + ConstraintId: proto.String("fixed64.gte_lte_exclusive"), + }, + ), }, "ignore_empty/valid/empty": { Message: &cases.Fixed64Ignore{Val: 0}, @@ -210,7 +305,12 @@ func fixed64Suite() suites.Suite { "ignore_empty/invalid/above": { Message: &cases.Fixed64Ignore{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("fixed64.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.gte"), + ConstraintId: proto.String("fixed64.gte_lte"), + }, + ), }, "compilation/wrong_type": { Message: &cases.Fixed64IncorrectType{Val: 123}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_float.go b/tools/protovalidate-conformance/internal/cases/cases_float.go index 0e2171a3..3e4c069c 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_float.go +++ b/tools/protovalidate-conformance/internal/cases/cases_float.go @@ -37,12 +37,22 @@ func floatSuite() suites.Suite { "const/invalid": { Message: &cases.FloatConst{Val: 4.56}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.const"), + ConstraintId: proto.String("float.const"), + }, + ), }, "const/nan": { Message: &cases.FloatConst{Val: float32(math.NaN())}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.const"), + ConstraintId: proto.String("float.const"), + }, + ), }, "in/valid": { Message: &cases.FloatIn{Val: 7.89}, @@ -51,12 +61,22 @@ func floatSuite() suites.Suite { "in/invalid": { Message: &cases.FloatIn{Val: 10.11}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.in"), + ConstraintId: proto.String("float.in"), + }, + ), }, "in/nan": { Message: &cases.FloatIn{Val: float32(math.NaN())}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.in"), + ConstraintId: proto.String("float.in"), + }, + ), }, "not_in/valid": { Message: &cases.FloatNotIn{Val: 1}, @@ -65,7 +85,12 @@ func floatSuite() suites.Suite { "not_in/invalid": { Message: &cases.FloatNotIn{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.not_in"), + ConstraintId: proto.String("float.not_in"), + }, + ), }, "not_in/nan": { Message: &cases.FloatNotIn{Val: float32(math.NaN())}, @@ -78,17 +103,32 @@ func floatSuite() suites.Suite { "lt/invalid/equal": { Message: &cases.FloatLT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.lt"), + ConstraintId: proto.String("float.lt"), + }, + ), }, "lt/invalid/greater": { Message: &cases.FloatLT{Val: 1}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.lt"), + ConstraintId: proto.String("float.lt"), + }, + ), }, "lt/invalid/nan": { Message: &cases.FloatLT{Val: float32(math.NaN())}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.lt"), + ConstraintId: proto.String("float.lt"), + }, + ), }, "lte/valid/less": { Message: &cases.FloatLTE{Val: 63}, @@ -101,12 +141,22 @@ func floatSuite() suites.Suite { "lte/invalid/greater": { Message: &cases.FloatLTE{Val: 65}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.lte"), + ConstraintId: proto.String("float.lte"), + }, + ), }, "lte/invalid/nan": { Message: &cases.FloatLTE{Val: float32(math.NaN())}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.lte"), + ConstraintId: proto.String("float.lte"), + }, + ), }, "gt/valid/greater": { Message: &cases.FloatGT{Val: 17}, @@ -115,17 +165,32 @@ func floatSuite() suites.Suite { "gt/invalid/equal": { Message: &cases.FloatGT{Val: 16}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), + ConstraintId: proto.String("float.gt"), + }, + ), }, "gt/invalid/less": { Message: &cases.FloatGT{Val: 15}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), + ConstraintId: proto.String("float.gt"), + }, + ), }, "gt/invalid/nan": { Message: &cases.FloatGT{Val: float32(math.NaN())}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), + ConstraintId: proto.String("float.gt"), + }, + ), }, "gte/valid/greater": { Message: &cases.FloatGTE{Val: 9}, @@ -138,12 +203,22 @@ func floatSuite() suites.Suite { "gte/invalid/less": { Message: &cases.FloatGTE{Val: 7}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gte"), + ConstraintId: proto.String("float.gte"), + }, + ), }, "gte/invalid/nan": { Message: &cases.FloatGTE{Val: float32(math.NaN())}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gte"), + ConstraintId: proto.String("float.gte"), + }, + ), }, "gt_lt/inclusive/valid/within": { Message: &cases.FloatGTLT{Val: 5}, @@ -152,27 +227,52 @@ func floatSuite() suites.Suite { "gt_lt/inclusive/invalid/above": { Message: &cases.FloatGTLT{Val: 11}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), + ConstraintId: proto.String("float.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/below": { Message: &cases.FloatGTLT{Val: -1}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), + ConstraintId: proto.String("float.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/max": { Message: &cases.FloatGTLT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), + ConstraintId: proto.String("float.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/min": { Message: &cases.FloatGTLT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), + ConstraintId: proto.String("float.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/nan": { Message: &cases.FloatGTLT{Val: float32(math.NaN())}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), + ConstraintId: proto.String("float.gt_lt"), + }, + ), }, "gt_lt/exclusive/valid/above": { Message: &cases.FloatExLTGT{Val: 11}, @@ -185,22 +285,42 @@ func floatSuite() suites.Suite { "gt_lt/exclusive/invalid/within": { Message: &cases.FloatExLTGT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), + ConstraintId: proto.String("float.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/max": { Message: &cases.FloatExLTGT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), + ConstraintId: proto.String("float.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/min": { Message: &cases.FloatExLTGT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), + ConstraintId: proto.String("float.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/nan": { Message: &cases.FloatExLTGT{Val: float32(math.NaN())}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), + ConstraintId: proto.String("float.gt_lt_exclusive"), + }, + ), }, "gte_lte/inclusive/valid/within": { Message: &cases.FloatGTELTE{Val: 200}, @@ -217,17 +337,32 @@ func floatSuite() suites.Suite { "gte_lte/inclusive/invalid/above": { Message: &cases.FloatGTELTE{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gte"), + ConstraintId: proto.String("float.gte_lte"), + }, + ), }, "gte_lte/inclusive/invalid/below": { Message: &cases.FloatGTELTE{Val: 100}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gte"), + ConstraintId: proto.String("float.gte_lte"), + }, + ), }, "gte_lte/inclusive/invalid/nan": { Message: &cases.FloatGTELTE{Val: float32(math.NaN())}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gte"), + ConstraintId: proto.String("float.gte_lte"), + }, + ), }, "gte_lte/exclusive/valid/above": { Message: &cases.FloatExGTELTE{Val: 300}, @@ -248,12 +383,22 @@ func floatSuite() suites.Suite { "gte_lte/exclusive/invalid/within": { Message: &cases.FloatExGTELTE{Val: 200}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gte_lte_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gte"), + ConstraintId: proto.String("float.gte_lte_exclusive"), + }, + ), }, "gte_lte/exclusive/invalid/nan": { Message: &cases.FloatExGTELTE{Val: float32(math.NaN())}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gte_lte_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gte"), + ConstraintId: proto.String("float.gte_lte_exclusive"), + }, + ), }, "finite/valid": { Message: &cases.FloatFinite{Val: 1}, @@ -263,7 +408,8 @@ func floatSuite() suites.Suite { Message: &cases.FloatFinite{Val: float32(math.NaN())}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.finite"), ConstraintId: proto.String("float.finite"), Message: proto.String("value must be finite"), }), @@ -272,9 +418,12 @@ func floatSuite() suites.Suite { Message: &cases.FloatFinite{Val: float32(math.Inf(1))}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.finite"), ConstraintId: proto.String("float.finite"), - Message: proto.String("value must be finite")}), + Message: proto.String("value must be finite"), + }, + ), }, "finite/inf/not_checked": { Message: &cases.FloatNotFinite{Val: float32(math.Inf(1))}, @@ -284,9 +433,12 @@ func floatSuite() suites.Suite { Message: &cases.FloatFinite{Val: float32(math.Inf(-1))}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.finite"), ConstraintId: proto.String("float.finite"), - Message: proto.String("value must be finite")}), + Message: proto.String("value must be finite"), + }, + ), }, "ignore_empty/valid/empty": { Message: &cases.FloatIgnore{Val: 0}, @@ -299,7 +451,12 @@ func floatSuite() suites.Suite { "ignore_empty/invalid/above": { Message: &cases.FloatIgnore{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("float.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gte"), + ConstraintId: proto.String("float.gte_lte"), + }, + ), }, "compilation/wrong_type": { Message: &cases.FloatIncorrectType{Val: 123}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_ignore.go b/tools/protovalidate-conformance/internal/cases/cases_ignore.go index c6cab197..8454af3e 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_ignore.go +++ b/tools/protovalidate-conformance/internal/cases/cases_ignore.go @@ -33,12 +33,20 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/scalar/optional/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto2ScalarOptionalIgnoreUnspecified{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarOptionalIgnoreUnspecified{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional/ignore_unspecified/invalid/default": suites.Case{ - Message: &cases.Proto2ScalarOptionalIgnoreUnspecified{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarOptionalIgnoreUnspecified{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional_with_default/ignore_unspecified/valid/unpopulated": suites.Case{ Message: &cases.Proto2ScalarOptionalIgnoreUnspecifiedWithDefault{}, @@ -49,16 +57,28 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/scalar/optional_with_default/ignore_unspecified/invalid/default": suites.Case{ - Message: &cases.Proto2ScalarOptionalIgnoreUnspecifiedWithDefault{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarOptionalIgnoreUnspecifiedWithDefault{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional_with_default/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto2ScalarOptionalIgnoreUnspecifiedWithDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarOptionalIgnoreUnspecifiedWithDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional_with_default/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.Proto2ScalarOptionalIgnoreUnspecifiedWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarOptionalIgnoreUnspecifiedWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.Proto2ScalarOptionalIgnoreEmpty{}, @@ -69,12 +89,20 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/scalar/optional/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto2ScalarOptionalIgnoreEmpty{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarOptionalIgnoreEmpty{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional/ignore_empty/invalid/default": suites.Case{ - Message: &cases.Proto2ScalarOptionalIgnoreEmpty{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarOptionalIgnoreEmpty{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional_with_default/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.Proto2ScalarOptionalIgnoreEmptyWithDefault{}, @@ -85,16 +113,28 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/scalar/optional_with_default/ignore_empty/invalid/default": suites.Case{ - Message: &cases.Proto2ScalarOptionalIgnoreEmptyWithDefault{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarOptionalIgnoreEmptyWithDefault{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional_with_default/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto2ScalarOptionalIgnoreEmptyWithDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarOptionalIgnoreEmptyWithDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional_with_default/ignore_empty/invalid/zero": suites.Case{ - Message: &cases.Proto2ScalarOptionalIgnoreEmptyWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarOptionalIgnoreEmptyWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional/ignore_default/valid/unpopulated": suites.Case{ Message: &cases.Proto2ScalarOptionalIgnoreDefault{}, @@ -105,8 +145,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/scalar/optional/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto2ScalarOptionalIgnoreDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarOptionalIgnoreDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional/ignore_default/valid/default": suites.Case{ Message: &cases.Proto2ScalarOptionalIgnoreDefault{Val: proto.Int32(0)}, @@ -125,76 +169,128 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/scalar/optional_with_default/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto2ScalarOptionalIgnoreDefaultWithDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarOptionalIgnoreDefaultWithDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional_with_default/ignore_default/invalid/zero": suites.Case{ - Message: &cases.Proto2ScalarOptionalIgnoreDefaultWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarOptionalIgnoreDefaultWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required/ignore_unspecified/valid/populated": suites.Case{ Message: &cases.Proto2ScalarRequiredIgnoreUnspecified{Val: proto.Int32(123)}, Expected: results.Success(true), }, "proto2/scalar/required/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto2ScalarRequiredIgnoreUnspecified{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarRequiredIgnoreUnspecified{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required/ignore_unspecified/invalid/default": suites.Case{ - Message: &cases.Proto2ScalarRequiredIgnoreUnspecified{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarRequiredIgnoreUnspecified{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required_with_default/ignore_unspecified/valid/populated": suites.Case{ Message: &cases.Proto2ScalarRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(123)}, Expected: results.Success(true), }, "proto2/scalar/required_with_default/ignore_unspecified/invalid/default": suites.Case{ - Message: &cases.Proto2ScalarRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required_with_default/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto2ScalarRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required_with_default/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.Proto2ScalarRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto2ScalarRequiredIgnoreEmpty{Val: proto.Int32(123)}, Expected: results.Success(true), }, "proto2/scalar/required/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto2ScalarRequiredIgnoreEmpty{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarRequiredIgnoreEmpty{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required/ignore_empty/invalid/default": suites.Case{ - Message: &cases.Proto2ScalarRequiredIgnoreEmpty{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarRequiredIgnoreEmpty{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required_with_default/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto2ScalarRequiredIgnoreEmptyWithDefault{Val: proto.Int32(123)}, Expected: results.Success(true), }, "proto2/scalar/required_with_default/ignore_empty/invalid/default": suites.Case{ - Message: &cases.Proto2ScalarRequiredIgnoreEmptyWithDefault{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarRequiredIgnoreEmptyWithDefault{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required_with_default/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto2ScalarRequiredIgnoreEmptyWithDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarRequiredIgnoreEmptyWithDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required_with_default/ignore_empty/invalid/zero": suites.Case{ - Message: &cases.Proto2ScalarRequiredIgnoreEmptyWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarRequiredIgnoreEmptyWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required/ignore_default/valid/populated": suites.Case{ Message: &cases.Proto2ScalarRequiredIgnoreDefault{Val: proto.Int32(123)}, Expected: results.Success(true), }, "proto2/scalar/required/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto2ScalarRequiredIgnoreDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarRequiredIgnoreDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required/ignore_default/valid/default": suites.Case{ Message: &cases.Proto2ScalarRequiredIgnoreDefault{Val: proto.Int32(0)}, @@ -209,12 +305,20 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/scalar/required_with_default/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto2ScalarRequiredIgnoreDefaultWithDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarRequiredIgnoreDefaultWithDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required_with_default/ignore_default/invalid/zero": suites.Case{ - Message: &cases.Proto2ScalarRequiredIgnoreDefaultWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2ScalarRequiredIgnoreDefaultWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/message/optional/ignore_unspecified/valid/unpopulated": suites.Case{ Message: &cases.Proto2MessageOptionalIgnoreUnspecified{}, @@ -230,13 +334,21 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto2MessageOptionalIgnoreUnspecified{ Val: &cases.Proto2MessageOptionalIgnoreUnspecified_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto2.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto2.message.ignore.empty"), + }), }, "proto2/message/optional/ignore_unspecified/invalid/default": suites.Case{ Message: &cases.Proto2MessageOptionalIgnoreUnspecified{ Val: &cases.Proto2MessageOptionalIgnoreUnspecified_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto2.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto2.message.ignore.empty"), + }), }, "proto2/message/optional/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.Proto2MessageOptionalIgnoreEmpty{}, @@ -252,13 +364,21 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto2MessageOptionalIgnoreEmpty{ Val: &cases.Proto2MessageOptionalIgnoreEmpty_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto2.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto2.message.ignore.empty"), + }), }, "proto2/message/optional/ignore_empty/invalid/default": suites.Case{ Message: &cases.Proto2MessageOptionalIgnoreEmpty{ Val: &cases.Proto2MessageOptionalIgnoreEmpty_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto2.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto2.message.ignore.empty"), + }), }, "proto2/message/optional/ignore_default/valid/unpopulated": suites.Case{ Message: &cases.Proto2MessageOptionalIgnoreDefault{}, @@ -274,7 +394,11 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto2MessageOptionalIgnoreDefault{ Val: &cases.Proto2MessageOptionalIgnoreDefault_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto2.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto2.message.ignore.empty"), + }), }, "proto2/message/optional/ignore_default/valid/default": suites.Case{ Message: &cases.Proto2MessageOptionalIgnoreDefault{ @@ -292,13 +416,21 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto2MessageRequiredIgnoreUnspecified{ Val: &cases.Proto2MessageRequiredIgnoreUnspecified_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto2.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto2.message.ignore.empty"), + }), }, "proto2/message/required/ignore_unspecified/invalid/default": suites.Case{ Message: &cases.Proto2MessageRequiredIgnoreUnspecified{ Val: &cases.Proto2MessageRequiredIgnoreUnspecified_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto2.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto2.message.ignore.empty"), + }), }, "proto2/message/required/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto2MessageRequiredIgnoreEmpty{ @@ -310,13 +442,21 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto2MessageRequiredIgnoreEmpty{ Val: &cases.Proto2MessageRequiredIgnoreEmpty_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto2.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto2.message.ignore.empty"), + }), }, "proto2/message/required/ignore_empty/invalid/default": suites.Case{ Message: &cases.Proto2MessageRequiredIgnoreEmpty{ Val: &cases.Proto2MessageRequiredIgnoreEmpty_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto2.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto2.message.ignore.empty"), + }), }, "proto2/message/required/ignore_default/valid/populated": suites.Case{ Message: &cases.Proto2MessageRequiredIgnoreDefault{ @@ -328,7 +468,11 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto2MessageRequiredIgnoreDefault{ Val: &cases.Proto2MessageRequiredIgnoreDefault_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto2.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto2.message.ignore.empty"), + }), }, "proto2/message/required/ignore_default/valid/default": suites.Case{ Message: &cases.Proto2MessageRequiredIgnoreDefault{ @@ -350,13 +494,21 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto2OneofIgnoreUnspecified{ O: &cases.Proto2OneofIgnoreUnspecified_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/oneof/ignore_unspecified/invalid/default": suites.Case{ Message: &cases.Proto2OneofIgnoreUnspecified{ O: &cases.Proto2OneofIgnoreUnspecified_Val{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/oneof_with_default/ignore_unspecified/valid/unpopulated": suites.Case{ Message: &cases.Proto2OneofIgnoreUnspecifiedWithDefault{}, @@ -372,19 +524,31 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto2OneofIgnoreUnspecifiedWithDefault{ O: &cases.Proto2OneofIgnoreUnspecifiedWithDefault_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/oneof_with_default/ignore_unspecified/invalid/default": suites.Case{ Message: &cases.Proto2OneofIgnoreUnspecifiedWithDefault{ O: &cases.Proto2OneofIgnoreUnspecifiedWithDefault_Val{Val: -42}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/oneof_with_default/ignore_unspecified/invalid/zero": suites.Case{ Message: &cases.Proto2OneofIgnoreUnspecifiedWithDefault{ O: &cases.Proto2OneofIgnoreUnspecifiedWithDefault_Val{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/oneof/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.Proto2OneofIgnoreEmpty{}, @@ -400,13 +564,21 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto2OneofIgnoreEmpty{ O: &cases.Proto2OneofIgnoreEmpty_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/oneof/ignore_empty/invalid/default": suites.Case{ Message: &cases.Proto2OneofIgnoreEmpty{ O: &cases.Proto2OneofIgnoreEmpty_Val{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/oneof_with_default/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.Proto2OneofIgnoreEmptyWithDefault{}, @@ -422,19 +594,31 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto2OneofIgnoreEmptyWithDefault{ O: &cases.Proto2OneofIgnoreEmptyWithDefault_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/oneof_with_default/ignore_empty/invalid/default": suites.Case{ Message: &cases.Proto2OneofIgnoreEmptyWithDefault{ O: &cases.Proto2OneofIgnoreEmptyWithDefault_Val{Val: -42}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/oneof_with_default/ignore_empty/invalid/zero": suites.Case{ Message: &cases.Proto2OneofIgnoreEmptyWithDefault{ O: &cases.Proto2OneofIgnoreEmptyWithDefault_Val{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/oneof/ignore_default/valid/unpopulated": suites.Case{ Message: &cases.Proto2OneofIgnoreDefault{}, @@ -450,7 +634,11 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto2OneofIgnoreDefault{ O: &cases.Proto2OneofIgnoreDefault_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/oneof/ignore_default/valid/default": suites.Case{ Message: &cases.Proto2OneofIgnoreDefault{ @@ -472,7 +660,11 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto2OneofIgnoreDefaultWithDefault{ O: &cases.Proto2OneofIgnoreDefaultWithDefault_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/oneof_with_default/ignore_default/valid/default": suites.Case{ Message: &cases.Proto2OneofIgnoreDefaultWithDefault{ @@ -484,15 +676,27 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto2OneofIgnoreDefaultWithDefault{ O: &cases.Proto2OneofIgnoreDefaultWithDefault_Val{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/repeated/ignore_unspecified/invalid/unpopulated": suites.Case{ - Message: &cases.Proto2RepeatedIgnoreUnspecified{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.Proto2RepeatedIgnoreUnspecified{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto2/repeated/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto2RepeatedIgnoreUnspecified{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.Proto2RepeatedIgnoreUnspecified{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto2/repeated/ignore_unspecified/valid/populated": suites.Case{ Message: &cases.Proto2RepeatedIgnoreUnspecified{Val: []int32{1, 2, 3}}, @@ -503,8 +707,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/repeated/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto2RepeatedIgnoreEmpty{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.Proto2RepeatedIgnoreEmpty{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto2/repeated/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto2RepeatedIgnoreEmpty{Val: []int32{1, 2, 3}}, @@ -515,20 +723,32 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/repeated/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto2RepeatedIgnoreDefault{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.Proto2RepeatedIgnoreDefault{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto2/repeated/ignore_default/valid/populated": suites.Case{ Message: &cases.Proto2RepeatedIgnoreDefault{Val: []int32{1, 2, 3}}, Expected: results.Success(true), }, "proto2/map/ignore_unspecified/invalid/unpopulated": suites.Case{ - Message: &cases.Proto2MapIgnoreUnspecified{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.Proto2MapIgnoreUnspecified{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto2/map/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto2MapIgnoreUnspecified{Val: map[int32]int32{1: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.Proto2MapIgnoreUnspecified{Val: map[int32]int32{1: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto2/map/ignore_unspecified/valid/populated": suites.Case{ Message: &cases.Proto2MapIgnoreUnspecified{Val: map[int32]int32{1: 1, 2: 2, 3: 3}}, @@ -539,8 +759,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/map/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto2MapIgnoreEmpty{Val: map[int32]int32{1: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.Proto2MapIgnoreEmpty{Val: map[int32]int32{1: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto2/map/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto2MapIgnoreEmpty{Val: map[int32]int32{1: 1, 2: 2, 3: 3}}, @@ -551,8 +775,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/map/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto2MapIgnoreDefault{Val: map[int32]int32{1: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.Proto2MapIgnoreDefault{Val: map[int32]int32{1: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto2/map/ignore_default/valid/populated": suites.Case{ Message: &cases.Proto2MapIgnoreDefault{Val: map[int32]int32{1: 1, 2: 2, 3: 3}}, @@ -563,20 +791,32 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/repeated/items/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto2RepeatedItemIgnoreUnspecified{Val: []int32{-42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2RepeatedItemIgnoreUnspecified{Val: []int32{-42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/repeated/items/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.Proto2RepeatedItemIgnoreUnspecified{Val: []int32{0}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2RepeatedItemIgnoreUnspecified{Val: []int32{0}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/repeated/items/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto2RepeatedItemIgnoreEmpty{Val: []int32{1}}, Expected: results.Success(true), }, "proto2/repeated/items/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto2RepeatedItemIgnoreEmpty{Val: []int32{-42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2RepeatedItemIgnoreEmpty{Val: []int32{-42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/repeated/items/ignore_empty/valid/zero": suites.Case{ Message: &cases.Proto2RepeatedItemIgnoreEmpty{Val: []int32{0}}, @@ -587,8 +827,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/repeated/items/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto2RepeatedItemIgnoreDefault{Val: []int32{-42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2RepeatedItemIgnoreDefault{Val: []int32{-42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/repeated/items/ignore_default/valid/zero": suites.Case{ Message: &cases.Proto2RepeatedItemIgnoreDefault{Val: []int32{0}}, @@ -599,20 +843,32 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/map/keys/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto2MapKeyIgnoreUnspecified{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ForKey: proto.Bool(true), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2MapKeyIgnoreUnspecified{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), ForKey: proto.Bool(true), + Rule: results.FieldPath("map.keys.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/map/keys/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.Proto2MapKeyIgnoreUnspecified{Val: map[int32]int32{0: 0}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ForKey: proto.Bool(true), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2MapKeyIgnoreUnspecified{Val: map[int32]int32{0: 0}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), ForKey: proto.Bool(true), + Rule: results.FieldPath("map.keys.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/map/keys/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto2MapKeyIgnoreEmpty{Val: map[int32]int32{1: 1}}, Expected: results.Success(true), }, "proto2/map/keys/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto2MapKeyIgnoreEmpty{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ForKey: proto.Bool(true), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2MapKeyIgnoreEmpty{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), ForKey: proto.Bool(true), + Rule: results.FieldPath("map.keys.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/map/keys/ignore_empty/valid/zero": suites.Case{ Message: &cases.Proto2MapKeyIgnoreEmpty{Val: map[int32]int32{0: 0}}, @@ -623,8 +879,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/map/keys/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto2MapKeyIgnoreDefault{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ForKey: proto.Bool(true), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2MapKeyIgnoreDefault{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), ForKey: proto.Bool(true), + Rule: results.FieldPath("map.keys.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/map/keys/ignore_default/valid/zero": suites.Case{ Message: &cases.Proto2MapKeyIgnoreDefault{Val: map[int32]int32{0: 0}}, @@ -635,20 +895,32 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/map/values/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto2MapValueIgnoreUnspecified{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2MapValueIgnoreUnspecified{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), + Rule: results.FieldPath("map.values.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/map/values/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.Proto2MapValueIgnoreUnspecified{Val: map[int32]int32{0: 0}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2MapValueIgnoreUnspecified{Val: map[int32]int32{0: 0}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("map.values.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/map/values/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto2MapValueIgnoreEmpty{Val: map[int32]int32{1: 1}}, Expected: results.Success(true), }, "proto2/map/values/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto2MapValueIgnoreEmpty{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2MapValueIgnoreEmpty{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), + Rule: results.FieldPath("map.values.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/map/values/ignore_empty/valid/zero": suites.Case{ Message: &cases.Proto2MapValueIgnoreEmpty{Val: map[int32]int32{0: 0}}, @@ -659,8 +931,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto2/map/values/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto2MapValueIgnoreDefault{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto2MapValueIgnoreDefault{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), + Rule: results.FieldPath("map.values.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/map/values/ignore_default/valid/zero": suites.Case{ Message: &cases.Proto2MapValueIgnoreDefault{Val: map[int32]int32{0: 0}}, @@ -675,12 +951,20 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/scalar/optional/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto3ScalarOptionalIgnoreUnspecified{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3ScalarOptionalIgnoreUnspecified{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/scalar/optional/ignore_unspecified/invalid/default": suites.Case{ - Message: &cases.Proto3ScalarOptionalIgnoreUnspecified{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3ScalarOptionalIgnoreUnspecified{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/scalar/optional/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.Proto3ScalarOptionalIgnoreEmpty{}, @@ -691,12 +975,20 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/scalar/optional/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto3ScalarOptionalIgnoreEmpty{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3ScalarOptionalIgnoreEmpty{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/scalar/optional/ignore_empty/invalid/default": suites.Case{ - Message: &cases.Proto3ScalarOptionalIgnoreEmpty{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3ScalarOptionalIgnoreEmpty{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/scalar/optional/ignore_default/valid/unpopulated": suites.Case{ Message: &cases.Proto3ScalarOptionalIgnoreDefault{}, @@ -707,8 +999,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/scalar/optional/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto3ScalarOptionalIgnoreDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3ScalarOptionalIgnoreDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/scalar/optional/ignore_default/valid/default": suites.Case{ Message: &cases.Proto3ScalarOptionalIgnoreDefault{Val: proto.Int32(0)}, @@ -719,20 +1015,32 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/scalar/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto3ScalarIgnoreUnspecified{Val: -123}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3ScalarIgnoreUnspecified{Val: -123}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/scalar/ignore_unspecified/invalid/default": suites.Case{ - Message: &cases.Proto3ScalarIgnoreUnspecified{Val: 0}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3ScalarIgnoreUnspecified{Val: 0}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/scalar/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto3ScalarIgnoreEmpty{Val: 123}, Expected: results.Success(true), }, "proto3/scalar/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto3ScalarIgnoreEmpty{Val: -123}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3ScalarIgnoreEmpty{Val: -123}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/scalar/ignore_empty/valid/default": suites.Case{ Message: &cases.Proto3ScalarIgnoreEmpty{Val: 0}, @@ -743,8 +1051,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/scalar/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto3ScalarIgnoreDefault{Val: -123}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3ScalarIgnoreDefault{Val: -123}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/scalar/ignore_default/valid/default": suites.Case{ Message: &cases.Proto3ScalarIgnoreDefault{Val: 0}, @@ -764,13 +1076,21 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto3MessageOptionalIgnoreUnspecified{ Val: &cases.Proto3MessageOptionalIgnoreUnspecified_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto3.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto3.message.ignore.empty"), + }), }, "proto3/message/optional/ignore_unspecified/invalid/default": suites.Case{ Message: &cases.Proto3MessageOptionalIgnoreUnspecified{ Val: &cases.Proto3MessageOptionalIgnoreUnspecified_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto3.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto3.message.ignore.empty"), + }), }, "proto3/message/optional/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.Proto3MessageOptionalIgnoreEmpty{}, @@ -786,13 +1106,21 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto3MessageOptionalIgnoreEmpty{ Val: &cases.Proto3MessageOptionalIgnoreEmpty_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto3.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto3.message.ignore.empty"), + }), }, "proto3/message/optional/ignore_empty/invalid/default": suites.Case{ Message: &cases.Proto3MessageOptionalIgnoreEmpty{ Val: &cases.Proto3MessageOptionalIgnoreEmpty_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto3.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto3.message.ignore.empty"), + }), }, "proto3/message/optional/ignore_default/valid/unpopulated": suites.Case{ Message: &cases.Proto3MessageOptionalIgnoreDefault{}, @@ -808,7 +1136,11 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto3MessageOptionalIgnoreDefault{ Val: &cases.Proto3MessageOptionalIgnoreDefault_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto3.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto3.message.ignore.empty"), + }), }, "proto3/message/optional/ignore_default/valid/default": suites.Case{ Message: &cases.Proto3MessageOptionalIgnoreDefault{ @@ -826,13 +1158,21 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto3MessageIgnoreUnspecified{ Val: &cases.Proto3MessageIgnoreUnspecified_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto3.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto3.message.ignore.empty"), + }), }, "proto3/message/ignore_unspecified/invalid/default": suites.Case{ Message: &cases.Proto3MessageIgnoreUnspecified{ Val: &cases.Proto3MessageIgnoreUnspecified_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto3.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto3.message.ignore.empty"), + }), }, "proto3/message/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto3MessageIgnoreEmpty{ @@ -844,13 +1184,21 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto3MessageIgnoreEmpty{ Val: &cases.Proto3MessageIgnoreEmpty_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto3.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto3.message.ignore.empty"), + }), }, "proto3/message/ignore_empty/invalid/default": suites.Case{ Message: &cases.Proto3MessageIgnoreEmpty{ Val: &cases.Proto3MessageIgnoreEmpty_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto3.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto3.message.ignore.empty"), + }), }, "proto3/message/ignore_default/valid/populated": suites.Case{ Message: &cases.Proto3MessageIgnoreDefault{ @@ -862,7 +1210,11 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto3MessageIgnoreDefault{ Val: &cases.Proto3MessageIgnoreDefault_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto3.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto3.message.ignore.empty"), + }), }, "proto3/message/ignore_default/valid/default": suites.Case{ Message: &cases.Proto3MessageIgnoreDefault{ @@ -884,13 +1236,21 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto3OneofIgnoreUnspecified{ O: &cases.Proto3OneofIgnoreUnspecified_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/oneof/ignore_unspecified/invalid/default": suites.Case{ Message: &cases.Proto3OneofIgnoreUnspecified{ O: &cases.Proto3OneofIgnoreUnspecified_Val{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/oneof/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.Proto3OneofIgnoreEmpty{}, @@ -906,13 +1266,21 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto3OneofIgnoreEmpty{ O: &cases.Proto3OneofIgnoreEmpty_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/oneof/ignore_empty/invalid/default": suites.Case{ Message: &cases.Proto3OneofIgnoreEmpty{ O: &cases.Proto3OneofIgnoreEmpty_Val{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/oneof/ignore_default/valid/unpopulated": suites.Case{ Message: &cases.Proto3OneofIgnoreDefault{}, @@ -928,7 +1296,11 @@ func ignoreSuite() suites.Suite { Message: &cases.Proto3OneofIgnoreDefault{ O: &cases.Proto3OneofIgnoreDefault_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/oneof/ignore_default/valid/default": suites.Case{ Message: &cases.Proto3OneofIgnoreDefault{ @@ -937,12 +1309,20 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/repeated/ignore_unspecified/invalid/unpopulated": suites.Case{ - Message: &cases.Proto3RepeatedIgnoreUnspecified{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.Proto3RepeatedIgnoreUnspecified{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto3/repeated/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto3RepeatedIgnoreUnspecified{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.Proto3RepeatedIgnoreUnspecified{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto3/repeated/ignore_unspecified/valid/populated": suites.Case{ Message: &cases.Proto3RepeatedIgnoreUnspecified{Val: []int32{1, 2, 3}}, @@ -953,8 +1333,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/repeated/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto3RepeatedIgnoreEmpty{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.Proto3RepeatedIgnoreEmpty{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto3/repeated/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto3RepeatedIgnoreEmpty{Val: []int32{1, 2, 3}}, @@ -965,20 +1349,32 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/repeated/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto3RepeatedIgnoreDefault{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.Proto3RepeatedIgnoreDefault{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto3/repeated/ignore_default/valid/populated": suites.Case{ Message: &cases.Proto3RepeatedIgnoreDefault{Val: []int32{1, 2, 3}}, Expected: results.Success(true), }, "proto3/map/ignore_unspecified/invalid/unpopulated": suites.Case{ - Message: &cases.Proto3MapIgnoreUnspecified{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.Proto3MapIgnoreUnspecified{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto3/map/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto3MapIgnoreUnspecified{Val: map[int32]int32{1: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.Proto3MapIgnoreUnspecified{Val: map[int32]int32{1: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto3/map/ignore_unspecified/valid/populated": suites.Case{ Message: &cases.Proto3MapIgnoreUnspecified{Val: map[int32]int32{1: 1, 2: 2, 3: 3}}, @@ -989,8 +1385,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/map/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto3MapIgnoreEmpty{Val: map[int32]int32{1: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.Proto3MapIgnoreEmpty{Val: map[int32]int32{1: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto3/map/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto3MapIgnoreEmpty{Val: map[int32]int32{1: 1, 2: 2, 3: 3}}, @@ -1001,8 +1401,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/map/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto3MapIgnoreDefault{Val: map[int32]int32{1: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.Proto3MapIgnoreDefault{Val: map[int32]int32{1: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto3/map/ignore_default/valid/populated": suites.Case{ Message: &cases.Proto3MapIgnoreDefault{Val: map[int32]int32{1: 1, 2: 2, 3: 3}}, @@ -1013,20 +1417,32 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/repeated/items/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto3RepeatedItemIgnoreUnspecified{Val: []int32{-42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3RepeatedItemIgnoreUnspecified{Val: []int32{-42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/repeated/items/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.Proto3RepeatedItemIgnoreUnspecified{Val: []int32{0}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3RepeatedItemIgnoreUnspecified{Val: []int32{0}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/repeated/items/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto3RepeatedItemIgnoreEmpty{Val: []int32{1}}, Expected: results.Success(true), }, "proto3/repeated/items/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto3RepeatedItemIgnoreEmpty{Val: []int32{-42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3RepeatedItemIgnoreEmpty{Val: []int32{-42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/repeated/items/ignore_empty/valid/zero": suites.Case{ Message: &cases.Proto3RepeatedItemIgnoreEmpty{Val: []int32{0}}, @@ -1037,8 +1453,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/repeated/items/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto3RepeatedItemIgnoreDefault{Val: []int32{-42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3RepeatedItemIgnoreDefault{Val: []int32{-42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/repeated/items/ignore_default/valid/zero": suites.Case{ Message: &cases.Proto3RepeatedItemIgnoreDefault{Val: []int32{0}}, @@ -1049,20 +1469,32 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/map/keys/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto3MapKeyIgnoreUnspecified{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ForKey: proto.Bool(true), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3MapKeyIgnoreUnspecified{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), ForKey: proto.Bool(true), + Rule: results.FieldPath("map.keys.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/map/keys/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.Proto3MapKeyIgnoreUnspecified{Val: map[int32]int32{0: 0}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ForKey: proto.Bool(true), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3MapKeyIgnoreUnspecified{Val: map[int32]int32{0: 0}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), ForKey: proto.Bool(true), + Rule: results.FieldPath("map.keys.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/map/keys/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto3MapKeyIgnoreEmpty{Val: map[int32]int32{1: 1}}, Expected: results.Success(true), }, "proto3/map/keys/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto3MapKeyIgnoreEmpty{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ForKey: proto.Bool(true), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3MapKeyIgnoreEmpty{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), ForKey: proto.Bool(true), + Rule: results.FieldPath("map.keys.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/map/keys/ignore_empty/valid/zero": suites.Case{ Message: &cases.Proto3MapKeyIgnoreEmpty{Val: map[int32]int32{0: 0}}, @@ -1073,8 +1505,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/map/keys/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto3MapKeyIgnoreDefault{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ForKey: proto.Bool(true), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3MapKeyIgnoreDefault{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), ForKey: proto.Bool(true), + Rule: results.FieldPath("map.keys.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/map/keys/ignore_default/valid/zero": suites.Case{ Message: &cases.Proto3MapKeyIgnoreDefault{Val: map[int32]int32{0: 0}}, @@ -1085,20 +1521,32 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/map/values/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.Proto3MapValueIgnoreUnspecified{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3MapValueIgnoreUnspecified{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), + Rule: results.FieldPath("map.values.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/map/values/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.Proto3MapValueIgnoreUnspecified{Val: map[int32]int32{0: 0}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3MapValueIgnoreUnspecified{Val: map[int32]int32{0: 0}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("map.values.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/map/values/ignore_empty/valid/populated": suites.Case{ Message: &cases.Proto3MapValueIgnoreEmpty{Val: map[int32]int32{1: 1}}, Expected: results.Success(true), }, "proto3/map/values/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.Proto3MapValueIgnoreEmpty{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3MapValueIgnoreEmpty{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), + Rule: results.FieldPath("map.values.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/map/values/ignore_empty/valid/zero": suites.Case{ Message: &cases.Proto3MapValueIgnoreEmpty{Val: map[int32]int32{0: 0}}, @@ -1109,8 +1557,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto3/map/values/ignore_default/invalid/populated": suites.Case{ - Message: &cases.Proto3MapValueIgnoreDefault{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Proto3MapValueIgnoreDefault{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), + Rule: results.FieldPath("map.values.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/map/values/ignore_default/valid/zero": suites.Case{ Message: &cases.Proto3MapValueIgnoreDefault{Val: map[int32]int32{0: 0}}, @@ -1125,12 +1577,20 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/explicit_presence/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarExplicitPresenceIgnoreUnspecified{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarExplicitPresenceIgnoreUnspecified{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence/ignore_unspecified/invalid/default": suites.Case{ - Message: &cases.EditionsScalarExplicitPresenceIgnoreUnspecified{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarExplicitPresenceIgnoreUnspecified{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence_with_default/ignore_unspecified/valid/unpopulated": suites.Case{ Message: &cases.EditionsScalarExplicitPresenceIgnoreUnspecifiedWithDefault{}, @@ -1141,16 +1601,28 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/explicit_presence_with_default/ignore_unspecified/invalid/default": suites.Case{ - Message: &cases.EditionsScalarExplicitPresenceIgnoreUnspecifiedWithDefault{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarExplicitPresenceIgnoreUnspecifiedWithDefault{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence_with_default/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarExplicitPresenceIgnoreUnspecifiedWithDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarExplicitPresenceIgnoreUnspecifiedWithDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence_with_default/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.EditionsScalarExplicitPresenceIgnoreUnspecifiedWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarExplicitPresenceIgnoreUnspecifiedWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.EditionsScalarExplicitPresenceIgnoreEmpty{}, @@ -1161,12 +1633,20 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/explicit_presence/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarExplicitPresenceIgnoreEmpty{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarExplicitPresenceIgnoreEmpty{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence/ignore_empty/invalid/default": suites.Case{ - Message: &cases.EditionsScalarExplicitPresenceIgnoreEmpty{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarExplicitPresenceIgnoreEmpty{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence_with_default/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.EditionsScalarExplicitPresenceIgnoreEmptyWithDefault{}, @@ -1177,16 +1657,28 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/explicit_presence_with_default/ignore_empty/invalid/default": suites.Case{ - Message: &cases.EditionsScalarExplicitPresenceIgnoreEmptyWithDefault{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarExplicitPresenceIgnoreEmptyWithDefault{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence_with_default/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarExplicitPresenceIgnoreEmptyWithDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarExplicitPresenceIgnoreEmptyWithDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence_with_default/ignore_empty/invalid/zero": suites.Case{ - Message: &cases.EditionsScalarExplicitPresenceIgnoreEmptyWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarExplicitPresenceIgnoreEmptyWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence/ignore_default/valid/unpopulated": suites.Case{ Message: &cases.EditionsScalarExplicitPresenceIgnoreDefault{}, @@ -1197,8 +1689,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/explicit_presence/ignore_default/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarExplicitPresenceIgnoreDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarExplicitPresenceIgnoreDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence/ignore_default/valid/default": suites.Case{ Message: &cases.EditionsScalarExplicitPresenceIgnoreDefault{Val: proto.Int32(0)}, @@ -1217,32 +1713,52 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/explicit_presence_with_default/ignore_default/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarExplicitPresenceIgnoreDefaultWithDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarExplicitPresenceIgnoreDefaultWithDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence_with_default/ignore_default/invalid/zero": suites.Case{ - Message: &cases.EditionsScalarExplicitPresenceIgnoreDefaultWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarExplicitPresenceIgnoreDefaultWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/implicit_presence/ignore_unspecified/valid/populated": suites.Case{ Message: &cases.EditionsScalarImplicitPresenceIgnoreUnspecified{Val: 123}, Expected: results.Success(true), }, "proto/2023/scalar/implicit_presence/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarImplicitPresenceIgnoreUnspecified{Val: -123}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarImplicitPresenceIgnoreUnspecified{Val: -123}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/implicit_presence/ignore_unspecified/invalid/default": suites.Case{ - Message: &cases.EditionsScalarImplicitPresenceIgnoreUnspecified{Val: 0}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarImplicitPresenceIgnoreUnspecified{Val: 0}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/implicit_presence/ignore_empty/valid/populated": suites.Case{ Message: &cases.EditionsScalarImplicitPresenceIgnoreEmpty{Val: 123}, Expected: results.Success(true), }, "proto/2023/scalar/implicit_presence/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarImplicitPresenceIgnoreEmpty{Val: -123}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarImplicitPresenceIgnoreEmpty{Val: -123}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/implicit_presence/ignore_empty/valid/default": suites.Case{ Message: &cases.EditionsScalarImplicitPresenceIgnoreEmpty{Val: 0}, @@ -1253,8 +1769,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/implicit_presence/ignore_default/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarImplicitPresenceIgnoreDefault{Val: -123}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarImplicitPresenceIgnoreDefault{Val: -123}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/implicit_presence/ignore_default/valid/default": suites.Case{ Message: &cases.EditionsScalarImplicitPresenceIgnoreDefault{Val: 0}, @@ -1265,64 +1785,108 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/legacy_required/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarLegacyRequiredIgnoreUnspecified{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarLegacyRequiredIgnoreUnspecified{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/legacy_required/ignore_unspecified/invalid/default": suites.Case{ - Message: &cases.EditionsScalarLegacyRequiredIgnoreUnspecified{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarLegacyRequiredIgnoreUnspecified{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/required_with_default/ignore_unspecified/valid/populated": suites.Case{ Message: &cases.EditionsScalarLegacyRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(123)}, Expected: results.Success(true), }, "proto/2023/scalar/required_with_default/ignore_unspecified/invalid/default": suites.Case{ - Message: &cases.EditionsScalarLegacyRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarLegacyRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/required_with_default/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarLegacyRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarLegacyRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/required_with_default/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.EditionsScalarLegacyRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarLegacyRequiredIgnoreUnspecifiedWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/legacy_required/ignore_empty/valid/populated": suites.Case{ Message: &cases.EditionsScalarLegacyRequiredIgnoreEmpty{Val: proto.Int32(123)}, Expected: results.Success(true), }, "proto/2023/scalar/legacy_required/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarLegacyRequiredIgnoreEmpty{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarLegacyRequiredIgnoreEmpty{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/legacy_required/ignore_empty/invalid/default": suites.Case{ - Message: &cases.EditionsScalarLegacyRequiredIgnoreEmpty{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarLegacyRequiredIgnoreEmpty{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/required_with_default/ignore_empty/valid/populated": suites.Case{ Message: &cases.EditionsScalarLegacyRequiredIgnoreEmptyWithDefault{Val: proto.Int32(123)}, Expected: results.Success(true), }, "proto/2023/scalar/required_with_default/ignore_empty/invalid/default": suites.Case{ - Message: &cases.EditionsScalarLegacyRequiredIgnoreEmptyWithDefault{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarLegacyRequiredIgnoreEmptyWithDefault{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/required_with_default/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarLegacyRequiredIgnoreEmptyWithDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarLegacyRequiredIgnoreEmptyWithDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/required_with_default/ignore_empty/invalid/zero": suites.Case{ - Message: &cases.EditionsScalarLegacyRequiredIgnoreEmptyWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarLegacyRequiredIgnoreEmptyWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/legacy_required/ignore_default/valid/populated": suites.Case{ Message: &cases.EditionsScalarLegacyRequiredIgnoreDefault{Val: proto.Int32(123)}, Expected: results.Success(true), }, "proto/2023/scalar/legacy_required/ignore_default/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarLegacyRequiredIgnoreDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarLegacyRequiredIgnoreDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/legacy_required/ignore_default/valid/default": suites.Case{ Message: &cases.EditionsScalarLegacyRequiredIgnoreDefault{Val: proto.Int32(0)}, @@ -1337,12 +1901,20 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/required_with_default/ignore_default/invalid/populated": suites.Case{ - Message: &cases.EditionsScalarLegacyRequiredIgnoreDefaultWithDefault{Val: proto.Int32(-123)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarLegacyRequiredIgnoreDefaultWithDefault{Val: proto.Int32(-123)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/required_with_default/ignore_default/invalid/zero": suites.Case{ - Message: &cases.EditionsScalarLegacyRequiredIgnoreDefaultWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsScalarLegacyRequiredIgnoreDefaultWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/message/explicit_presence/length_prefixed/ignore_unspecified/valid/unpopulated": suites.Case{ Message: &cases.EditionsMessageExplicitPresenceIgnoreUnspecified{}, @@ -1358,13 +1930,21 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsMessageExplicitPresenceIgnoreUnspecified{ Val: &cases.EditionsMessageExplicitPresenceIgnoreUnspecified_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/explicit_presence/length_prefixed/ignore_unspecified/invalid/default": suites.Case{ Message: &cases.EditionsMessageExplicitPresenceIgnoreUnspecified{ Val: &cases.EditionsMessageExplicitPresenceIgnoreUnspecified_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/explicit_presence/delimited/ignore_unspecified/valid/unpopulated": suites.Case{ Message: &cases.EditionsMessageExplicitPresenceDelimitedIgnoreUnspecified{}, @@ -1380,13 +1960,21 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsMessageExplicitPresenceDelimitedIgnoreUnspecified{ Val: &cases.EditionsMessageExplicitPresenceDelimitedIgnoreUnspecified_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/explicit_presence/delimited/ignore_unspecified/invalid/default": suites.Case{ Message: &cases.EditionsMessageExplicitPresenceDelimitedIgnoreUnspecified{ Val: &cases.EditionsMessageExplicitPresenceDelimitedIgnoreUnspecified_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/explicit_presence/length_prefixed/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.EditionsMessageExplicitPresenceIgnoreEmpty{}, @@ -1402,13 +1990,21 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsMessageExplicitPresenceIgnoreEmpty{ Val: &cases.EditionsMessageExplicitPresenceIgnoreEmpty_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/explicit_presence/length_prefixed/ignore_empty/invalid/default": suites.Case{ Message: &cases.EditionsMessageExplicitPresenceIgnoreEmpty{ Val: &cases.EditionsMessageExplicitPresenceIgnoreEmpty_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/explicit_presence/delimited/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.EditionsMessageExplicitPresenceDelimitedIgnoreEmpty{}, @@ -1424,13 +2020,21 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsMessageExplicitPresenceDelimitedIgnoreEmpty{ Val: &cases.EditionsMessageExplicitPresenceDelimitedIgnoreEmpty_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/explicit_presence/delimited/ignore_empty/invalid/default": suites.Case{ Message: &cases.EditionsMessageExplicitPresenceDelimitedIgnoreEmpty{ Val: &cases.EditionsMessageExplicitPresenceDelimitedIgnoreEmpty_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/explicit_presence/length_prefixed/ignore_default/valid/unpopulated": suites.Case{ Message: &cases.EditionsMessageExplicitPresenceIgnoreDefault{}, @@ -1446,7 +2050,11 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsMessageExplicitPresenceIgnoreDefault{ Val: &cases.EditionsMessageExplicitPresenceIgnoreDefault_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/explicit_presence/length_prefixed/ignore_default/valid/default": suites.Case{ Message: &cases.EditionsMessageExplicitPresenceIgnoreDefault{ @@ -1468,7 +2076,11 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsMessageExplicitPresenceDelimitedIgnoreDefault{ Val: &cases.EditionsMessageExplicitPresenceDelimitedIgnoreDefault_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/explicit_presence/delimited/ignore_default/valid/default": suites.Case{ Message: &cases.EditionsMessageExplicitPresenceDelimitedIgnoreDefault{ @@ -1486,13 +2098,21 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsMessageLegacyRequiredIgnoreUnspecified{ Val: &cases.EditionsMessageLegacyRequiredIgnoreUnspecified_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/legacy_required/length_prefixed/ignore_unspecified/invalid/default": suites.Case{ Message: &cases.EditionsMessageLegacyRequiredIgnoreUnspecified{ Val: &cases.EditionsMessageLegacyRequiredIgnoreUnspecified_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/legacy_required/delimited/ignore_unspecified/valid/populated": suites.Case{ Message: &cases.EditionsMessageLegacyRequiredDelimitedIgnoreUnspecified{ @@ -1504,13 +2124,21 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsMessageLegacyRequiredDelimitedIgnoreUnspecified{ Val: &cases.EditionsMessageLegacyRequiredDelimitedIgnoreUnspecified_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/legacy_required/delimited/ignore_unspecified/invalid/default": suites.Case{ Message: &cases.EditionsMessageLegacyRequiredDelimitedIgnoreUnspecified{ Val: &cases.EditionsMessageLegacyRequiredDelimitedIgnoreUnspecified_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/legacy_required/length_prefixed/ignore_empty/valid/populated": suites.Case{ Message: &cases.EditionsMessageLegacyRequiredIgnoreEmpty{ @@ -1522,13 +2150,21 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsMessageLegacyRequiredIgnoreEmpty{ Val: &cases.EditionsMessageLegacyRequiredIgnoreEmpty_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/legacy_required/length_prefixed/ignore_empty/invalid/default": suites.Case{ Message: &cases.EditionsMessageLegacyRequiredIgnoreEmpty{ Val: &cases.EditionsMessageLegacyRequiredIgnoreEmpty_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/legacy_required/delimited/ignore_empty/valid/populated": suites.Case{ Message: &cases.EditionsMessageLegacyRequiredDelimitedIgnoreEmpty{ @@ -1540,13 +2176,21 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsMessageLegacyRequiredDelimitedIgnoreEmpty{ Val: &cases.EditionsMessageLegacyRequiredDelimitedIgnoreEmpty_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/legacy_required/delimited/ignore_empty/invalid/default": suites.Case{ Message: &cases.EditionsMessageLegacyRequiredDelimitedIgnoreEmpty{ Val: &cases.EditionsMessageLegacyRequiredDelimitedIgnoreEmpty_Msg{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/legacy_required/length_prefixed/ignore_default/valid/populated": suites.Case{ Message: &cases.EditionsMessageLegacyRequiredIgnoreDefault{ @@ -1558,7 +2202,11 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsMessageLegacyRequiredIgnoreDefault{ Val: &cases.EditionsMessageLegacyRequiredIgnoreDefault_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/legacy_required/length_prefixed/ignore_default/valid/default": suites.Case{ Message: &cases.EditionsMessageLegacyRequiredIgnoreDefault{ @@ -1576,7 +2224,11 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsMessageLegacyRequiredDelimitedIgnoreDefault{ Val: &cases.EditionsMessageLegacyRequiredDelimitedIgnoreDefault_Msg{Val: proto.String("bar")}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("proto.editions.message.ignore.empty")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("proto.editions.message.ignore.empty"), + }), }, "proto/2023/message/legacy_required/delimited/ignore_default/valid/default": suites.Case{ Message: &cases.EditionsMessageLegacyRequiredDelimitedIgnoreDefault{ @@ -1598,13 +2250,21 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsOneofIgnoreUnspecified{ O: &cases.EditionsOneofIgnoreUnspecified_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/oneof/ignore_unspecified/invalid/default": suites.Case{ Message: &cases.EditionsOneofIgnoreUnspecified{ O: &cases.EditionsOneofIgnoreUnspecified_Val{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/oneof_with_default/ignore_unspecified/valid/unpopulated": suites.Case{ Message: &cases.EditionsOneofIgnoreUnspecifiedWithDefault{}, @@ -1620,19 +2280,31 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsOneofIgnoreUnspecifiedWithDefault{ O: &cases.EditionsOneofIgnoreUnspecifiedWithDefault_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/oneof_with_default/ignore_unspecified/invalid/default": suites.Case{ Message: &cases.EditionsOneofIgnoreUnspecifiedWithDefault{ O: &cases.EditionsOneofIgnoreUnspecifiedWithDefault_Val{Val: -42}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/oneof_with_default/ignore_unspecified/invalid/zero": suites.Case{ Message: &cases.EditionsOneofIgnoreUnspecifiedWithDefault{ O: &cases.EditionsOneofIgnoreUnspecifiedWithDefault_Val{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/oneof/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.EditionsOneofIgnoreEmpty{}, @@ -1648,13 +2320,21 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsOneofIgnoreEmpty{ O: &cases.EditionsOneofIgnoreEmpty_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/oneof/ignore_empty/invalid/default": suites.Case{ Message: &cases.EditionsOneofIgnoreEmpty{ O: &cases.EditionsOneofIgnoreEmpty_Val{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/oneof_with_default/ignore_empty/valid/unpopulated": suites.Case{ Message: &cases.EditionsOneofIgnoreEmptyWithDefault{}, @@ -1670,19 +2350,31 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsOneofIgnoreEmptyWithDefault{ O: &cases.EditionsOneofIgnoreEmptyWithDefault_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/oneof_with_default/ignore_empty/invalid/default": suites.Case{ Message: &cases.EditionsOneofIgnoreEmptyWithDefault{ O: &cases.EditionsOneofIgnoreEmptyWithDefault_Val{Val: -42}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/oneof_with_default/ignore_empty/invalid/zero": suites.Case{ Message: &cases.EditionsOneofIgnoreEmptyWithDefault{ O: &cases.EditionsOneofIgnoreEmptyWithDefault_Val{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/oneof/ignore_default/valid/unpopulated": suites.Case{ Message: &cases.EditionsOneofIgnoreDefault{}, @@ -1698,7 +2390,11 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsOneofIgnoreDefault{ O: &cases.EditionsOneofIgnoreDefault_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/oneof/ignore_default/valid/default": suites.Case{ Message: &cases.EditionsOneofIgnoreDefault{ @@ -1720,7 +2416,11 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsOneofIgnoreDefaultWithDefault{ O: &cases.EditionsOneofIgnoreDefaultWithDefault_Val{Val: -123}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/oneof_with_default/ignore_default/valid/default": suites.Case{ Message: &cases.EditionsOneofIgnoreDefaultWithDefault{ @@ -1732,27 +2432,47 @@ func ignoreSuite() suites.Suite { Message: &cases.EditionsOneofIgnoreDefaultWithDefault{ O: &cases.EditionsOneofIgnoreDefaultWithDefault_Val{}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/repeated/compact/ignore_unspecified/invalid/unpopulated": suites.Case{ - Message: &cases.EditionsRepeatedIgnoreUnspecified{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.EditionsRepeatedIgnoreUnspecified{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto/2023/repeated/compact/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.EditionsRepeatedIgnoreUnspecified{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.EditionsRepeatedIgnoreUnspecified{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto/2023/repeated/compact/ignore_unspecified/valid/populated": suites.Case{ Message: &cases.EditionsRepeatedIgnoreUnspecified{Val: []int32{1, 2, 3}}, Expected: results.Success(true), }, "proto/2023/repeated/expanded/ignore_unspecified/invalid/unpopulated": suites.Case{ - Message: &cases.EditionsRepeatedExpandedIgnoreUnspecified{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.EditionsRepeatedExpandedIgnoreUnspecified{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto/2023/repeated/expanded/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.EditionsRepeatedExpandedIgnoreUnspecified{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.EditionsRepeatedExpandedIgnoreUnspecified{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto/2023/repeated/expanded/ignore_unspecified/valid/populated": suites.Case{ Message: &cases.EditionsRepeatedExpandedIgnoreUnspecified{Val: []int32{1, 2, 3}}, @@ -1763,8 +2483,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/repeated/compact/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.EditionsRepeatedIgnoreEmpty{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.EditionsRepeatedIgnoreEmpty{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto/2023/repeated/compact/ignore_empty/valid/populated": suites.Case{ Message: &cases.EditionsRepeatedIgnoreEmpty{Val: []int32{1, 2, 3}}, @@ -1775,8 +2499,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/repeated/expanded/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.EditionsRepeatedExpandedIgnoreEmpty{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.EditionsRepeatedExpandedIgnoreEmpty{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto/2023/repeated/expanded/ignore_empty/valid/populated": suites.Case{ Message: &cases.EditionsRepeatedExpandedIgnoreEmpty{Val: []int32{1, 2, 3}}, @@ -1787,8 +2515,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/repeated/compact/ignore_default/invalid/populated": suites.Case{ - Message: &cases.EditionsRepeatedIgnoreDefault{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.EditionsRepeatedIgnoreDefault{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto/2023/repeated/compact/ignore_default/valid/populated": suites.Case{ Message: &cases.EditionsRepeatedIgnoreDefault{Val: []int32{1, 2, 3}}, @@ -1799,20 +2531,32 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/repeated/expanded/ignore_default/invalid/populated": suites.Case{ - Message: &cases.EditionsRepeatedExpandedIgnoreDefault{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.EditionsRepeatedExpandedIgnoreDefault{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto/2023/repeated/expanded/ignore_default/valid/populated": suites.Case{ Message: &cases.EditionsRepeatedExpandedIgnoreDefault{Val: []int32{1, 2, 3}}, Expected: results.Success(true), }, "proto/2023/map/ignore_unspecified/invalid/unpopulated": suites.Case{ - Message: &cases.EditionsMapIgnoreUnspecified{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.EditionsMapIgnoreUnspecified{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto/2023/map/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.EditionsMapIgnoreUnspecified{Val: map[int32]int32{1: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.EditionsMapIgnoreUnspecified{Val: map[int32]int32{1: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto/2023/map/ignore_unspecified/valid/populated": suites.Case{ Message: &cases.EditionsMapIgnoreUnspecified{Val: map[int32]int32{1: 1, 2: 2, 3: 3}}, @@ -1823,8 +2567,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/map/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.EditionsMapIgnoreEmpty{Val: map[int32]int32{1: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.EditionsMapIgnoreEmpty{Val: map[int32]int32{1: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto/2023/map/ignore_empty/valid/populated": suites.Case{ Message: &cases.EditionsMapIgnoreEmpty{Val: map[int32]int32{1: 1, 2: 2, 3: 3}}, @@ -1835,8 +2583,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/map/ignore_default/invalid/populated": suites.Case{ - Message: &cases.EditionsMapIgnoreDefault{Val: map[int32]int32{1: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.EditionsMapIgnoreDefault{Val: map[int32]int32{1: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto/2023/map/ignore_default/valid/populated": suites.Case{ Message: &cases.EditionsMapIgnoreDefault{Val: map[int32]int32{1: 1, 2: 2, 3: 3}}, @@ -1847,32 +2599,52 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/repeated/compact/items/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.EditionsRepeatedItemIgnoreUnspecified{Val: []int32{-42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsRepeatedItemIgnoreUnspecified{Val: []int32{-42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/repeated/compact/items/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.EditionsRepeatedItemIgnoreUnspecified{Val: []int32{0}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsRepeatedItemIgnoreUnspecified{Val: []int32{0}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/repeated/expanded/items/ignore_unspecified/valid/populated": suites.Case{ Message: &cases.EditionsRepeatedExpandedItemIgnoreUnspecified{Val: []int32{1}}, Expected: results.Success(true), }, "proto/2023/repeated/expanded/items/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.EditionsRepeatedExpandedItemIgnoreUnspecified{Val: []int32{-42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsRepeatedExpandedItemIgnoreUnspecified{Val: []int32{-42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/repeated/expanded/items/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.EditionsRepeatedExpandedItemIgnoreUnspecified{Val: []int32{0}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsRepeatedExpandedItemIgnoreUnspecified{Val: []int32{0}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/repeated/compact/items/ignore_empty/valid/populated": suites.Case{ Message: &cases.EditionsRepeatedItemIgnoreEmpty{Val: []int32{1}}, Expected: results.Success(true), }, "proto/2023/repeated/compact/items/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.EditionsRepeatedItemIgnoreEmpty{Val: []int32{-42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsRepeatedItemIgnoreEmpty{Val: []int32{-42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/repeated/compact/items/ignore_empty/valid/zero": suites.Case{ Message: &cases.EditionsRepeatedItemIgnoreEmpty{Val: []int32{0}}, @@ -1883,8 +2655,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/repeated/expanded/items/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.EditionsRepeatedExpandedItemIgnoreEmpty{Val: []int32{-42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsRepeatedExpandedItemIgnoreEmpty{Val: []int32{-42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/repeated/expanded/items/ignore_empty/valid/zero": suites.Case{ Message: &cases.EditionsRepeatedExpandedItemIgnoreEmpty{Val: []int32{0}}, @@ -1895,8 +2671,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/repeated/compact/items/ignore_default/invalid/populated": suites.Case{ - Message: &cases.EditionsRepeatedItemIgnoreDefault{Val: []int32{-42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsRepeatedItemIgnoreDefault{Val: []int32{-42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/repeated/compact/items/ignore_default/valid/zero": suites.Case{ Message: &cases.EditionsRepeatedItemIgnoreDefault{Val: []int32{0}}, @@ -1907,8 +2687,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/repeated/expanded/items/ignore_default/invalid/populated": suites.Case{ - Message: &cases.EditionsRepeatedExpandedItemIgnoreDefault{Val: []int32{-42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsRepeatedExpandedItemIgnoreDefault{Val: []int32{-42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/repeated/expanded/items/ignore_default/valid/zero": suites.Case{ Message: &cases.EditionsRepeatedExpandedItemIgnoreDefault{Val: []int32{0}}, @@ -1919,20 +2703,32 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/map/keys/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.EditionsMapKeyIgnoreUnspecified{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ForKey: proto.Bool(true), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsMapKeyIgnoreUnspecified{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), ForKey: proto.Bool(true), + Rule: results.FieldPath("map.keys.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/map/keys/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.EditionsMapKeyIgnoreUnspecified{Val: map[int32]int32{0: 0}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ForKey: proto.Bool(true), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsMapKeyIgnoreUnspecified{Val: map[int32]int32{0: 0}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), ForKey: proto.Bool(true), + Rule: results.FieldPath("map.keys.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/map/keys/ignore_empty/valid/populated": suites.Case{ Message: &cases.EditionsMapKeyIgnoreEmpty{Val: map[int32]int32{1: 1}}, Expected: results.Success(true), }, "proto/2023/map/keys/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.EditionsMapKeyIgnoreEmpty{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ForKey: proto.Bool(true), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsMapKeyIgnoreEmpty{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), ForKey: proto.Bool(true), + Rule: results.FieldPath("map.keys.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/map/keys/ignore_empty/valid/zero": suites.Case{ Message: &cases.EditionsMapKeyIgnoreEmpty{Val: map[int32]int32{0: 0}}, @@ -1943,8 +2739,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/map/keys/ignore_default/invalid/populated": suites.Case{ - Message: &cases.EditionsMapKeyIgnoreDefault{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ForKey: proto.Bool(true), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsMapKeyIgnoreDefault{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), ForKey: proto.Bool(true), + Rule: results.FieldPath("map.keys.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/map/keys/ignore_default/valid/zero": suites.Case{ Message: &cases.EditionsMapKeyIgnoreDefault{Val: map[int32]int32{0: 0}}, @@ -1955,20 +2755,32 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/map/values/ignore_unspecified/invalid/populated": suites.Case{ - Message: &cases.EditionsMapValueIgnoreUnspecified{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsMapValueIgnoreUnspecified{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), + Rule: results.FieldPath("map.values.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/map/values/ignore_unspecified/invalid/zero": suites.Case{ - Message: &cases.EditionsMapValueIgnoreUnspecified{Val: map[int32]int32{0: 0}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsMapValueIgnoreUnspecified{Val: map[int32]int32{0: 0}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("map.values.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/map/values/ignore_empty/valid/populated": suites.Case{ Message: &cases.EditionsMapValueIgnoreEmpty{Val: map[int32]int32{1: 1}}, Expected: results.Success(true), }, "proto/2023/map/values/ignore_empty/invalid/populated": suites.Case{ - Message: &cases.EditionsMapValueIgnoreEmpty{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsMapValueIgnoreEmpty{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), + Rule: results.FieldPath("map.values.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/map/values/ignore_empty/valid/zero": suites.Case{ Message: &cases.EditionsMapValueIgnoreEmpty{Val: map[int32]int32{0: 0}}, @@ -1979,8 +2791,12 @@ func ignoreSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/map/values/ignore_default/invalid/populated": suites.Case{ - Message: &cases.EditionsMapValueIgnoreDefault{Val: map[int32]int32{-42: -42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[-42]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.EditionsMapValueIgnoreDefault{Val: map[int32]int32{-42: -42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[-42]"), + Rule: results.FieldPath("map.values.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/map/values/ignore_default/valid/zero": suites.Case{ Message: &cases.EditionsMapValueIgnoreDefault{Val: map[int32]int32{0: 0}}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_ignore_empty.go b/tools/protovalidate-conformance/internal/cases/cases_ignore_empty.go index 21c4eaca..e6b27edc 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_ignore_empty.go +++ b/tools/protovalidate-conformance/internal/cases/cases_ignore_empty.go @@ -29,12 +29,20 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto2/scalar/optional/nonzero/invalid": suites.Case{ - Message: &cases.IgnoreEmptyProto2ScalarOptional{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyProto2ScalarOptional{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional/zero": suites.Case{ - Message: &cases.IgnoreEmptyProto2ScalarOptional{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyProto2ScalarOptional{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional/unset": suites.Case{ Message: &cases.IgnoreEmptyProto2ScalarOptional{}, @@ -45,12 +53,20 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto2/scalar/optional_with_default/nonzero/invalid": suites.Case{ - Message: &cases.IgnoreEmptyProto2ScalarOptionalWithDefault{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyProto2ScalarOptionalWithDefault{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional_with_default/zero": suites.Case{ - Message: &cases.IgnoreEmptyProto2ScalarOptionalWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyProto2ScalarOptionalWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/optional_with_default/default": suites.Case{ Message: &cases.IgnoreEmptyProto2ScalarOptionalWithDefault{Val: proto.Int32(42)}, @@ -65,20 +81,32 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto2/scalar/required/nonzero/invalid": suites.Case{ - Message: &cases.IgnoreEmptyProto2ScalarRequired{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyProto2ScalarRequired{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/scalar/required/zero": suites.Case{ - Message: &cases.IgnoreEmptyProto2ScalarRequired{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyProto2ScalarRequired{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/message/nonzero": suites.Case{ Message: &cases.IgnoreEmptyProto2Message{Val: &cases.IgnoreEmptyProto2Message_Msg{Val: proto.String("foo")}}, Expected: results.Success(true), }, "proto2/message/zero": suites.Case{ - Message: &cases.IgnoreEmptyProto2Message{Val: &cases.IgnoreEmptyProto2Message_Msg{}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("ignore_empty.proto2.message")}), + Message: &cases.IgnoreEmptyProto2Message{Val: &cases.IgnoreEmptyProto2Message_Msg{}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("ignore_empty.proto2.message"), + }), }, "proto2/message/unset": suites.Case{ Message: &cases.IgnoreEmptyProto2Message{}, @@ -89,8 +117,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto2/oneof/zero": suites.Case{ - Message: &cases.IgnoreEmptyProto2Oneof{O: &cases.IgnoreEmptyProto2Oneof_Val{}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyProto2Oneof{O: &cases.IgnoreEmptyProto2Oneof_Val{}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto2/oneof/unset": suites.Case{ Message: &cases.IgnoreEmptyProto2Oneof{}, @@ -101,8 +133,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto2/repeated/noempty/invalid": suites.Case{ - Message: &cases.IgnoreEmptyProto2Repeated{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.IgnoreEmptyProto2Repeated{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto2/repeated/empty": suites.Case{ Message: &cases.IgnoreEmptyProto2Repeated{}, @@ -113,8 +149,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto2/map/nonempty/invalid": suites.Case{ - Message: &cases.IgnoreEmptyProto2Map{Val: map[int32]int32{0: 0}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.IgnoreEmptyProto2Map{Val: map[int32]int32{0: 0}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto2/map/empty": suites.Case{ Message: &cases.IgnoreEmptyProto2Map{}, @@ -125,8 +165,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto3/scalar/nonzero/invalid": suites.Case{ - Message: &cases.IgnoreEmptyProto3Scalar{Val: -42}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyProto3Scalar{Val: -42}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/scalar/zero": suites.Case{ Message: &cases.IgnoreEmptyProto3Scalar{Val: 0}, @@ -137,8 +181,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto3/scalar/optional/zero": suites.Case{ - Message: &cases.IgnoreEmptyProto3OptionalScalar{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyProto3OptionalScalar{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/scalar/optional/unset": suites.Case{ Message: &cases.IgnoreEmptyProto3OptionalScalar{}, @@ -149,8 +197,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto3/message/zero": suites.Case{ - Message: &cases.IgnoreEmptyProto3Message{Val: &cases.IgnoreEmptyProto3Message_Msg{}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("ignore_empty.proto3.message")}), + Message: &cases.IgnoreEmptyProto3Message{Val: &cases.IgnoreEmptyProto3Message_Msg{}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("ignore_empty.proto3.message"), + }), }, "proto3/message/unset": suites.Case{ Message: &cases.IgnoreEmptyProto3Message{}, @@ -161,8 +213,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto3/oneof/zero": suites.Case{ - Message: &cases.IgnoreEmptyProto3Oneof{O: &cases.IgnoreEmptyProto3Oneof_Val{}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyProto3Oneof{O: &cases.IgnoreEmptyProto3Oneof_Val{}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/oneof/unset": suites.Case{ Message: &cases.IgnoreEmptyProto3Oneof{}, @@ -173,8 +229,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto3/repeated/noempty/invalid": suites.Case{ - Message: &cases.IgnoreEmptyProto3Repeated{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.IgnoreEmptyProto3Repeated{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto3/repeated/empty": suites.Case{ Message: &cases.IgnoreEmptyProto3Repeated{}, @@ -185,8 +245,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto3/map/nonempty/invalid": suites.Case{ - Message: &cases.IgnoreEmptyProto3Map{Val: map[int32]int32{0: 0}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.IgnoreEmptyProto3Map{Val: map[int32]int32{0: 0}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto3/map/empty": suites.Case{ Message: &cases.IgnoreEmptyProto3Map{}, @@ -201,8 +265,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto3/repeated/items/nonzero/invalid": suites.Case{ - Message: &cases.IgnoreEmptyRepeatedItems{Val: []int32{-1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val[0]"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyRepeatedItems{Val: []int32{-1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto3/map/keys/zero": suites.Case{ Message: &cases.IgnoreEmptyMapPairs{Val: map[string]int32{"": 42}}, @@ -213,8 +281,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto3/map/keys/nonzero/invalid": suites.Case{ - Message: &cases.IgnoreEmptyMapPairs{Val: map[string]int32{"x": 42}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String(`val["x"]`), ForKey: proto.Bool(true), ConstraintId: proto.String("string.min_len")}), + Message: &cases.IgnoreEmptyMapPairs{Val: map[string]int32{"x": 42}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath(`val["x"]`), ForKey: proto.Bool(true), + Rule: results.FieldPath("map.keys.string.min_len"), + ConstraintId: proto.String("string.min_len"), + }), }, "proto3/map/values/zero": suites.Case{ Message: &cases.IgnoreEmptyMapPairs{Val: map[string]int32{"foo": 0}}, @@ -225,20 +297,32 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto3/map/values/nonzero/invalid": suites.Case{ - Message: &cases.IgnoreEmptyMapPairs{Val: map[string]int32{"foo": -1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String(`val["foo"]`), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyMapPairs{Val: map[string]int32{"foo": -1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath(`val["foo"]`), + Rule: results.FieldPath("map.values.int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence/nonzero/valid": suites.Case{ Message: &cases.IgnoreEmptyEditionsScalarExplicitPresence{Val: proto.Int32(42)}, Expected: results.Success(true), }, "proto/2023/scalar/explicit_presence/nonzero/invalid": suites.Case{ - Message: &cases.IgnoreEmptyEditionsScalarExplicitPresence{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyEditionsScalarExplicitPresence{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence/zero": suites.Case{ - Message: &cases.IgnoreEmptyEditionsScalarExplicitPresence{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyEditionsScalarExplicitPresence{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence/unset": suites.Case{ Message: &cases.IgnoreEmptyEditionsScalarExplicitPresence{}, @@ -249,12 +333,20 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/explicit_presence_with_default/nonzero/invalid": suites.Case{ - Message: &cases.IgnoreEmptyEditionsScalarExplicitPresenceWithDefault{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyEditionsScalarExplicitPresenceWithDefault{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence_with_default/zero": suites.Case{ - Message: &cases.IgnoreEmptyEditionsScalarExplicitPresenceWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyEditionsScalarExplicitPresenceWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/explicit_presence_with_default/default": suites.Case{ Message: &cases.IgnoreEmptyEditionsScalarExplicitPresenceWithDefault{Val: proto.Int32(42)}, @@ -269,8 +361,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/implicit_presence/nonzero/invalid": suites.Case{ - Message: &cases.IgnoreEmptyEditionsScalarImplicitPresence{Val: -42}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyEditionsScalarImplicitPresence{Val: -42}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/implicit_presence/zero": suites.Case{ Message: &cases.IgnoreEmptyEditionsScalarImplicitPresence{Val: 0}, @@ -281,32 +377,52 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/legacy_required/nonzero/invalid": suites.Case{ - Message: &cases.IgnoreEmptyEditionsScalarLegacyRequired{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyEditionsScalarLegacyRequired{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/legacy_required/zero": suites.Case{ - Message: &cases.IgnoreEmptyEditionsScalarLegacyRequired{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyEditionsScalarLegacyRequired{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/legacy_required_with_default/nonzero/valid": suites.Case{ Message: &cases.IgnoreEmptyEditionsScalarLegacyRequiredWithDefault{Val: proto.Int32(42)}, Expected: results.Success(true), }, "proto/2023/scalar/legacy_required_with_default/nonzero/invalid": suites.Case{ - Message: &cases.IgnoreEmptyEditionsScalarLegacyRequiredWithDefault{Val: proto.Int32(-42)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyEditionsScalarLegacyRequiredWithDefault{Val: proto.Int32(-42)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/scalar/legacy_required_with_default/zero": suites.Case{ - Message: &cases.IgnoreEmptyEditionsScalarLegacyRequiredWithDefault{Val: proto.Int32(0)}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyEditionsScalarLegacyRequiredWithDefault{Val: proto.Int32(0)}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/message/explicit_presence/length_prefixed/nonzero": suites.Case{ Message: &cases.IgnoreEmptyEditionsMessageExplicitPresence{Val: &cases.IgnoreEmptyEditionsMessageExplicitPresence_Msg{Val: proto.String("foo")}}, Expected: results.Success(true), }, "proto/2023/message/explicit_presence/length_prefixed/zero": suites.Case{ - Message: &cases.IgnoreEmptyEditionsMessageExplicitPresence{Val: &cases.IgnoreEmptyEditionsMessageExplicitPresence_Msg{}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("ignore_empty.editions.message")}), + Message: &cases.IgnoreEmptyEditionsMessageExplicitPresence{Val: &cases.IgnoreEmptyEditionsMessageExplicitPresence_Msg{}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("ignore_empty.editions.message"), + }), }, "proto/2023/message/explicit_presence/length_prefixed/unset": suites.Case{ Message: &cases.IgnoreEmptyEditionsMessageExplicitPresence{}, @@ -317,8 +433,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/message/explicit_presence/delimited/zero": suites.Case{ - Message: &cases.IgnoreEmptyEditionsMessageExplicitPresenceDelimited{Val: &cases.IgnoreEmptyEditionsMessageExplicitPresenceDelimited_Msg{}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("ignore_empty.editions.message")}), + Message: &cases.IgnoreEmptyEditionsMessageExplicitPresenceDelimited{Val: &cases.IgnoreEmptyEditionsMessageExplicitPresenceDelimited_Msg{}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("ignore_empty.editions.message"), + }), }, "proto/2023/message/explicit_presence/delimited/unset": suites.Case{ Message: &cases.IgnoreEmptyEditionsMessageExplicitPresenceDelimited{}, @@ -329,8 +449,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/oneof/zero": suites.Case{ - Message: &cases.IgnoreEmptyEditionsOneof{O: &cases.IgnoreEmptyEditionsOneof_Val{}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.IgnoreEmptyEditionsOneof{O: &cases.IgnoreEmptyEditionsOneof_Val{}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "proto/2023/oneof/unset": suites.Case{ Message: &cases.IgnoreEmptyEditionsOneof{}, @@ -341,8 +465,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/repeated/compact/noempty/invalid": suites.Case{ - Message: &cases.IgnoreEmptyEditionsRepeated{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.IgnoreEmptyEditionsRepeated{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto/2023/repeated/compact/empty": suites.Case{ Message: &cases.IgnoreEmptyEditionsRepeated{}, @@ -353,8 +481,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/repeated/expanded/noempty/invalid": suites.Case{ - Message: &cases.IgnoreEmptyEditionsRepeatedExpanded{Val: []int32{1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("repeated.min_items")}), + Message: &cases.IgnoreEmptyEditionsRepeatedExpanded{Val: []int32{1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), + ConstraintId: proto.String("repeated.min_items"), + }), }, "proto/2023/repeated/expanded/empty": suites.Case{ Message: &cases.IgnoreEmptyEditionsRepeatedExpanded{}, @@ -365,8 +497,12 @@ func ignoreEmptySuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/map/nonempty/invalid": suites.Case{ - Message: &cases.IgnoreEmptyEditionsMap{Val: map[int32]int32{0: 0}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("map.min_pairs")}), + Message: &cases.IgnoreEmptyEditionsMap{Val: map[int32]int32{0: 0}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), + ConstraintId: proto.String("map.min_pairs"), + }), }, "proto/2023/map/empty": suites.Case{ Message: &cases.IgnoreEmptyEditionsMap{}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_int32.go b/tools/protovalidate-conformance/internal/cases/cases_int32.go index b3e12d57..cbeba3ed 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_int32.go +++ b/tools/protovalidate-conformance/internal/cases/cases_int32.go @@ -35,7 +35,12 @@ func int32Suite() suites.Suite { "const/invalid": { Message: &cases.Int32Const{Val: 2}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.const"), + ConstraintId: proto.String("int32.const"), + }, + ), }, "in/valid": { Message: &cases.Int32In{Val: 3}, @@ -44,7 +49,12 @@ func int32Suite() suites.Suite { "in/invalid": { Message: &cases.Int32In{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.in"), + ConstraintId: proto.String("int32.in"), + }, + ), }, "not_in/valid": { Message: &cases.Int32NotIn{Val: 1}, @@ -53,7 +63,12 @@ func int32Suite() suites.Suite { "not_in/invalid": { Message: &cases.Int32NotIn{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.not_in"), + ConstraintId: proto.String("int32.not_in"), + }, + ), }, "lt/valid/less": { Message: &cases.Int32LT{Val: -1}, @@ -62,12 +77,22 @@ func int32Suite() suites.Suite { "lt/invalid/equal": { Message: &cases.Int32LT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.lt"), + ConstraintId: proto.String("int32.lt"), + }, + ), }, "lt/invalid/greater": { Message: &cases.Int32LT{Val: 1}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.lt"), + ConstraintId: proto.String("int32.lt"), + }, + ), }, "lte/valid/less": { Message: &cases.Int32LTE{Val: 63}, @@ -80,7 +105,12 @@ func int32Suite() suites.Suite { "lte/invalid/greater": { Message: &cases.Int32LTE{Val: 65}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.lte"), + ConstraintId: proto.String("int32.lte"), + }, + ), }, "gt/valid/greater": { Message: &cases.Int32GT{Val: 17}, @@ -89,12 +119,22 @@ func int32Suite() suites.Suite { "gt/invalid/equal": { Message: &cases.Int32GT{Val: 16}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }, + ), }, "gt/invalid/less": { Message: &cases.Int32GT{Val: 15}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }, + ), }, "gte/valid/greater": { Message: &cases.Int32GTE{Val: 9}, @@ -107,7 +147,12 @@ func int32Suite() suites.Suite { "gte/invalid/less": { Message: &cases.Int32GTE{Val: 7}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gte"), + ConstraintId: proto.String("int32.gte"), + }, + ), }, "gt_lt/inclusive/valid/within": { Message: &cases.Int32GTLT{Val: 5}, @@ -116,22 +161,42 @@ func int32Suite() suites.Suite { "gt_lt/inclusive/invalid/above": { Message: &cases.Int32GTLT{Val: 11}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/below": { Message: &cases.Int32GTLT{Val: -1}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/max": { Message: &cases.Int32GTLT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/min": { Message: &cases.Int32GTLT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt_lt"), + }, + ), }, "gt_lt/exclusive/valid/above": { Message: &cases.Int32ExLTGT{Val: 11}, @@ -144,17 +209,32 @@ func int32Suite() suites.Suite { "gt_lt/exclusive/invalid/within": { Message: &cases.Int32ExLTGT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/max": { Message: &cases.Int32ExLTGT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/min": { Message: &cases.Int32ExLTGT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt_lt_exclusive"), + }, + ), }, "gte_lte/inclusive/valid/within": { Message: &cases.Int32GTELTE{Val: 200}, @@ -171,12 +251,22 @@ func int32Suite() suites.Suite { "gte_lte/inclusive/invalid/above": { Message: &cases.Int32GTELTE{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gte"), + ConstraintId: proto.String("int32.gte_lte"), + }, + ), }, "gte_lte/inclusive/invalid/below": { Message: &cases.Int32GTELTE{Val: 100}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gte"), + ConstraintId: proto.String("int32.gte_lte"), + }, + ), }, "gte_lte/exclusive/valid/above": { Message: &cases.Int32ExGTELTE{Val: 300}, @@ -197,7 +287,12 @@ func int32Suite() suites.Suite { "gte_lte/exclusive/invalid/within": { Message: &cases.Int32ExGTELTE{Val: 200}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gte_lte_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gte"), + ConstraintId: proto.String("int32.gte_lte_exclusive"), + }, + ), }, "ignore_empty/valid/empty": { Message: &cases.Int32Ignore{Val: 0}, @@ -210,7 +305,12 @@ func int32Suite() suites.Suite { "ignore_empty/invalid/above": { Message: &cases.Int32Ignore{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int32.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gte"), + ConstraintId: proto.String("int32.gte_lte"), + }, + ), }, "compilation/wrong_type": { Message: &cases.Int32IncorrectType{Val: 123}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_int64.go b/tools/protovalidate-conformance/internal/cases/cases_int64.go index 7abc829f..ec41980f 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_int64.go +++ b/tools/protovalidate-conformance/internal/cases/cases_int64.go @@ -35,7 +35,12 @@ func int64Suite() suites.Suite { "const/invalid": { Message: &cases.Int64Const{Val: 2}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.const"), + ConstraintId: proto.String("int64.const"), + }, + ), }, "in/valid": { Message: &cases.Int64In{Val: 3}, @@ -44,7 +49,12 @@ func int64Suite() suites.Suite { "in/invalid": { Message: &cases.Int64In{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.in"), + ConstraintId: proto.String("int64.in"), + }, + ), }, "not_in/valid": { Message: &cases.Int64NotIn{Val: 1}, @@ -53,7 +63,12 @@ func int64Suite() suites.Suite { "not_in/invalid": { Message: &cases.Int64NotIn{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.not_in"), + ConstraintId: proto.String("int64.not_in"), + }, + ), }, "lt/valid/less": { Message: &cases.Int64LT{Val: -1}, @@ -62,12 +77,22 @@ func int64Suite() suites.Suite { "lt/invalid/equal": { Message: &cases.Int64LT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.lt"), + ConstraintId: proto.String("int64.lt"), + }, + ), }, "lt/invalid/greater": { Message: &cases.Int64LT{Val: 1}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.lt"), + ConstraintId: proto.String("int64.lt"), + }, + ), }, "lte/valid/less": { Message: &cases.Int64LTE{Val: 63}, @@ -80,7 +105,12 @@ func int64Suite() suites.Suite { "lte/invalid/greater": { Message: &cases.Int64LTE{Val: 65}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.lte"), + ConstraintId: proto.String("int64.lte"), + }, + ), }, "gt/valid/greater": { Message: &cases.Int64GT{Val: 17}, @@ -89,12 +119,22 @@ func int64Suite() suites.Suite { "gt/invalid/equal": { Message: &cases.Int64GT{Val: 16}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gt"), + ConstraintId: proto.String("int64.gt"), + }, + ), }, "gt/invalid/less": { Message: &cases.Int64GT{Val: 15}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gt"), + ConstraintId: proto.String("int64.gt"), + }, + ), }, "gte/valid/greater": { Message: &cases.Int64GTE{Val: 9}, @@ -107,7 +147,12 @@ func int64Suite() suites.Suite { "gte/invalid/less": { Message: &cases.Int64GTE{Val: 7}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gte"), + ConstraintId: proto.String("int64.gte"), + }, + ), }, "gt_lt/inclusive/valid/within": { Message: &cases.Int64GTLT{Val: 5}, @@ -116,22 +161,42 @@ func int64Suite() suites.Suite { "gt_lt/inclusive/invalid/above": { Message: &cases.Int64GTLT{Val: 11}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gt"), + ConstraintId: proto.String("int64.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/below": { Message: &cases.Int64GTLT{Val: -1}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gt"), + ConstraintId: proto.String("int64.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/max": { Message: &cases.Int64GTLT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gt"), + ConstraintId: proto.String("int64.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/min": { Message: &cases.Int64GTLT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gt"), + ConstraintId: proto.String("int64.gt_lt"), + }, + ), }, "gt_lt/exclusive/valid/above": { Message: &cases.Int64ExLTGT{Val: 11}, @@ -144,17 +209,32 @@ func int64Suite() suites.Suite { "gt_lt/exclusive/invalid/within": { Message: &cases.Int64ExLTGT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gt"), + ConstraintId: proto.String("int64.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/max": { Message: &cases.Int64ExLTGT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gt"), + ConstraintId: proto.String("int64.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/min": { Message: &cases.Int64ExLTGT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gt"), + ConstraintId: proto.String("int64.gt_lt_exclusive"), + }, + ), }, "gte_lte/inclusive/valid/within": { Message: &cases.Int64GTELTE{Val: 200}, @@ -171,12 +251,22 @@ func int64Suite() suites.Suite { "gte_lte/inclusive/invalid/above": { Message: &cases.Int64GTELTE{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gte"), + ConstraintId: proto.String("int64.gte_lte"), + }, + ), }, "gte_lte/inclusive/invalid/below": { Message: &cases.Int64GTELTE{Val: 100}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gte"), + ConstraintId: proto.String("int64.gte_lte"), + }, + ), }, "gte_lte/exclusive/valid/above": { Message: &cases.Int64ExGTELTE{Val: 300}, @@ -197,7 +287,12 @@ func int64Suite() suites.Suite { "gte_lte/exclusive/invalid/within": { Message: &cases.Int64ExGTELTE{Val: 200}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gte_lte_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gte"), + ConstraintId: proto.String("int64.gte_lte_exclusive"), + }, + ), }, "ignore_empty/valid/empty": { Message: &cases.Int64Ignore{Val: 0}, @@ -210,7 +305,12 @@ func int64Suite() suites.Suite { "ignore_empty/invalid/above": { Message: &cases.Int64Ignore{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("int64.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gte"), + ConstraintId: proto.String("int64.gte_lte"), + }, + ), }, "big_constraints/valid": { Message: &cases.Int64BigConstraints{ diff --git a/tools/protovalidate-conformance/internal/cases/cases_kitchensink.go b/tools/protovalidate-conformance/internal/cases/cases_kitchensink.go index 699333fc..354b3fa4 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_kitchensink.go +++ b/tools/protovalidate-conformance/internal/cases/cases_kitchensink.go @@ -40,37 +40,43 @@ func kitchenSinkSuite() suites.Suite { Message: &cases.KitchenSinkMessage{Val: &cases.ComplexTestMsg{}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val.bytes_val"), + Field: results.FieldPath("val.bytes_val"), + Rule: results.FieldPath("bytes.const"), ConstraintId: proto.String("bytes.const"), Message: proto.String("value must be 0099"), }, &validate.Violation{ - FieldPath: proto.String("val.double_in"), + Field: results.FieldPath("val.double_in"), + Rule: results.FieldPath("double.in"), ConstraintId: proto.String("double.in"), Message: proto.String("value must be in list [456.789000, 123.000000]"), }, &validate.Violation{ - FieldPath: proto.String("val.enum_const"), + Field: results.FieldPath("val.enum_const"), + Rule: results.FieldPath("enum.const"), ConstraintId: proto.String("enum.const"), Message: proto.String("value must equal 2"), }, &validate.Violation{ - FieldPath: proto.String("val.int_const"), + Field: results.FieldPath("val.int_const"), + Rule: results.FieldPath("int32.const"), ConstraintId: proto.String("int32.const"), Message: proto.String("value must equal 5"), }, &validate.Violation{ - FieldPath: proto.String("val.o"), + Field: results.FieldPath("val.o"), ConstraintId: proto.String("required"), Message: proto.String("exactly one field is required in oneof"), }, &validate.Violation{ - FieldPath: proto.String("val.dur_val"), + Field: results.FieldPath("val.dur_val"), + Rule: results.FieldPath("required"), ConstraintId: proto.String("required"), Message: proto.String("value is required"), }, &validate.Violation{ - FieldPath: proto.String("val.const"), + Field: results.FieldPath("val.const"), + Rule: results.FieldPath("string.const"), ConstraintId: proto.String("string.const"), Message: proto.String("value must equal `abcd`"), }, @@ -80,72 +86,84 @@ func kitchenSinkSuite() suites.Suite { Message: &cases.KitchenSinkMessage{Val: &cases.ComplexTestMsg{Another: &cases.ComplexTestMsg{}}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val.another.bytes_val"), + Field: results.FieldPath("val.another.bytes_val"), + Rule: results.FieldPath("bytes.const"), ConstraintId: proto.String("bytes.const"), Message: proto.String("value must be 0099"), }, &validate.Violation{ - FieldPath: proto.String("val.bytes_val"), + Field: results.FieldPath("val.bytes_val"), + Rule: results.FieldPath("bytes.const"), ConstraintId: proto.String("bytes.const"), Message: proto.String("value must be 0099"), }, &validate.Violation{ - FieldPath: proto.String("val.another.double_in"), + Field: results.FieldPath("val.another.double_in"), + Rule: results.FieldPath("double.in"), ConstraintId: proto.String("double.in"), Message: proto.String("value must be in list [456.789000, 123.000000]"), }, &validate.Violation{ - FieldPath: proto.String("val.double_in"), + Field: results.FieldPath("val.double_in"), + Rule: results.FieldPath("double.in"), ConstraintId: proto.String("double.in"), Message: proto.String("value must be in list [456.789000, 123.000000]"), }, &validate.Violation{ - FieldPath: proto.String("val.another.enum_const"), + Field: results.FieldPath("val.another.enum_const"), + Rule: results.FieldPath("enum.const"), ConstraintId: proto.String("enum.const"), Message: proto.String("value must equal 2"), }, &validate.Violation{ - FieldPath: proto.String("val.enum_const"), + Field: results.FieldPath("val.enum_const"), + Rule: results.FieldPath("enum.const"), ConstraintId: proto.String("enum.const"), Message: proto.String("value must equal 2"), }, &validate.Violation{ - FieldPath: proto.String("val.another.int_const"), + Field: results.FieldPath("val.another.int_const"), + Rule: results.FieldPath("int32.const"), ConstraintId: proto.String("int32.const"), Message: proto.String("value must equal 5"), }, &validate.Violation{ - FieldPath: proto.String("val.int_const"), + Field: results.FieldPath("val.int_const"), + Rule: results.FieldPath("int32.const"), ConstraintId: proto.String("int32.const"), Message: proto.String("value must equal 5"), }, &validate.Violation{ - FieldPath: proto.String("val.o"), + Field: results.FieldPath("val.o"), ConstraintId: proto.String("required"), Message: proto.String("exactly one field is required in oneof"), }, &validate.Violation{ - FieldPath: proto.String("val.another.o"), + Field: results.FieldPath("val.another.o"), ConstraintId: proto.String("required"), Message: proto.String("exactly one field is required in oneof"), }, &validate.Violation{ - FieldPath: proto.String("val.another.dur_val"), + Field: results.FieldPath("val.another.dur_val"), + Rule: results.FieldPath("required"), ConstraintId: proto.String("required"), Message: proto.String("value is required"), }, &validate.Violation{ - FieldPath: proto.String("val.dur_val"), + Field: results.FieldPath("val.dur_val"), + Rule: results.FieldPath("required"), ConstraintId: proto.String("required"), Message: proto.String("value is required"), }, &validate.Violation{ - FieldPath: proto.String("val.another.const"), + Field: results.FieldPath("val.another.const"), + Rule: results.FieldPath("string.const"), ConstraintId: proto.String("string.const"), Message: proto.String("value must equal `abcd`"), }, &validate.Violation{ - FieldPath: proto.String("val.const"), + Field: results.FieldPath("val.const"), + Rule: results.FieldPath("string.const"), ConstraintId: proto.String("string.const"), Message: proto.String("value must equal `abcd`"), }, @@ -155,72 +173,84 @@ func kitchenSinkSuite() suites.Suite { Message: &cases.KitchenSinkMessage{Val: &cases.ComplexTestMsg{Const: "abcd", BoolConst: true, Nested: &cases.ComplexTestMsg{}}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val.bool_const"), + Field: results.FieldPath("val.bool_const"), + Rule: results.FieldPath("bool.const"), ConstraintId: proto.String("bool.const"), Message: proto.String("value must equal false"), }, &validate.Violation{ - FieldPath: proto.String("val.bytes_val"), + Field: results.FieldPath("val.bytes_val"), + Rule: results.FieldPath("bytes.const"), ConstraintId: proto.String("bytes.const"), Message: proto.String("value must be 0099"), }, &validate.Violation{ - FieldPath: proto.String("val.nested.bytes_val"), + Field: results.FieldPath("val.nested.bytes_val"), + Rule: results.FieldPath("bytes.const"), ConstraintId: proto.String("bytes.const"), Message: proto.String("value must be 0099"), }, &validate.Violation{ - FieldPath: proto.String("val.double_in"), + Field: results.FieldPath("val.double_in"), + Rule: results.FieldPath("double.in"), ConstraintId: proto.String("double.in"), Message: proto.String("value must be in list [456.789000, 123.000000]"), }, &validate.Violation{ - FieldPath: proto.String("val.nested.double_in"), + Field: results.FieldPath("val.nested.double_in"), + Rule: results.FieldPath("double.in"), ConstraintId: proto.String("double.in"), Message: proto.String("value must be in list [456.789000, 123.000000]"), }, &validate.Violation{ - FieldPath: proto.String("val.enum_const"), + Field: results.FieldPath("val.enum_const"), + Rule: results.FieldPath("enum.const"), ConstraintId: proto.String("enum.const"), Message: proto.String("value must equal 2"), }, &validate.Violation{ - FieldPath: proto.String("val.nested.enum_const"), + Field: results.FieldPath("val.nested.enum_const"), + Rule: results.FieldPath("enum.const"), ConstraintId: proto.String("enum.const"), Message: proto.String("value must equal 2"), }, &validate.Violation{ - FieldPath: proto.String("val.int_const"), + Field: results.FieldPath("val.int_const"), + Rule: results.FieldPath("int32.const"), ConstraintId: proto.String("int32.const"), Message: proto.String("value must equal 5"), }, &validate.Violation{ - FieldPath: proto.String("val.nested.int_const"), + Field: results.FieldPath("val.nested.int_const"), + Rule: results.FieldPath("int32.const"), ConstraintId: proto.String("int32.const"), Message: proto.String("value must equal 5"), }, &validate.Violation{ - FieldPath: proto.String("val.o"), + Field: results.FieldPath("val.o"), ConstraintId: proto.String("required"), Message: proto.String("exactly one field is required in oneof"), }, &validate.Violation{ - FieldPath: proto.String("val.dur_val"), + Field: results.FieldPath("val.dur_val"), + Rule: results.FieldPath("required"), ConstraintId: proto.String("required"), Message: proto.String("value is required"), }, &validate.Violation{ - FieldPath: proto.String("val.nested.o"), + Field: results.FieldPath("val.nested.o"), ConstraintId: proto.String("required"), Message: proto.String("exactly one field is required in oneof"), }, &validate.Violation{ - FieldPath: proto.String("val.nested.dur_val"), + Field: results.FieldPath("val.nested.dur_val"), + Rule: results.FieldPath("required"), ConstraintId: proto.String("required"), Message: proto.String("value is required"), }, &validate.Violation{ - FieldPath: proto.String("val.nested.const"), + Field: results.FieldPath("val.nested.const"), + Rule: results.FieldPath("string.const"), ConstraintId: proto.String("string.const"), Message: proto.String("value must equal `abcd`"), }, @@ -230,67 +260,79 @@ func kitchenSinkSuite() suites.Suite { Message: &cases.KitchenSinkMessage{Val: &cases.ComplexTestMsg{BoolConst: true, FloatVal: &wrapperspb.FloatValue{}, TsVal: ×tamppb.Timestamp{}, FloatConst: 8, AnyVal: &anypb.Any{TypeUrl: "asdf"}, RepTsVal: []*timestamppb.Timestamp{{Nanos: 1}}}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val.any_val"), + Field: results.FieldPath("val.any_val"), + Rule: results.FieldPath("any.in"), ConstraintId: proto.String("any.in"), Message: proto.String("type URL must be in the allow list"), }, &validate.Violation{ - FieldPath: proto.String("val.bool_const"), + Field: results.FieldPath("val.bool_const"), + Rule: results.FieldPath("bool.const"), ConstraintId: proto.String("bool.const"), Message: proto.String("value must equal false"), }, &validate.Violation{ - FieldPath: proto.String("val.bytes_val"), + Field: results.FieldPath("val.bytes_val"), + Rule: results.FieldPath("bytes.const"), ConstraintId: proto.String("bytes.const"), Message: proto.String("value must be 0099"), }, &validate.Violation{ - FieldPath: proto.String("val.double_in"), + Field: results.FieldPath("val.double_in"), + Rule: results.FieldPath("double.in"), ConstraintId: proto.String("double.in"), Message: proto.String("value must be in list [456.789000, 123.000000]"), }, &validate.Violation{ - FieldPath: proto.String("val.enum_const"), + Field: results.FieldPath("val.enum_const"), + Rule: results.FieldPath("enum.const"), ConstraintId: proto.String("enum.const"), Message: proto.String("value must equal 2"), }, &validate.Violation{ - FieldPath: proto.String("val.float_val"), + Field: results.FieldPath("val.float_val"), + Rule: results.FieldPath("float.gt"), ConstraintId: proto.String("float.gt"), Message: proto.String("value must be greater than 0"), }, &validate.Violation{ - FieldPath: proto.String("val.float_const"), + Field: results.FieldPath("val.float_const"), + Rule: results.FieldPath("float.lt"), ConstraintId: proto.String("float.lt"), Message: proto.String("value must be less than 8"), }, &validate.Violation{ - FieldPath: proto.String("val.int_const"), + Field: results.FieldPath("val.int_const"), + Rule: results.FieldPath("int32.const"), ConstraintId: proto.String("int32.const"), Message: proto.String("value must equal 5"), }, &validate.Violation{ - FieldPath: proto.String("val.o"), + Field: results.FieldPath("val.o"), ConstraintId: proto.String("required"), Message: proto.String("exactly one field is required in oneof"), }, &validate.Violation{ - FieldPath: proto.String("val.dur_val"), + Field: results.FieldPath("val.dur_val"), + Rule: results.FieldPath("required"), ConstraintId: proto.String("required"), Message: proto.String("value is required"), }, &validate.Violation{ - FieldPath: proto.String("val.const"), + Field: results.FieldPath("val.const"), + Rule: results.FieldPath("string.const"), ConstraintId: proto.String("string.const"), Message: proto.String("value must equal `abcd`"), }, &validate.Violation{ - FieldPath: proto.String("val.ts_val"), + Field: results.FieldPath("val.ts_val"), + Rule: results.FieldPath("timestamp.gt"), ConstraintId: proto.String("timestamp.gt"), Message: proto.String("value must be greater than 1970-01-01T00:00:07Z"), }, &validate.Violation{ - FieldPath: proto.String("val.rep_ts_val[0]"), + Field: results.FieldPath("val.rep_ts_val[0]"), + Rule: results.FieldPath("repeated.items.timestamp.gte"), ConstraintId: proto.String("timestamp.gte"), Message: proto.String("value must be greater than or equal to 1970-01-01T00:00:00.001Z"), }, diff --git a/tools/protovalidate-conformance/internal/cases/cases_map.go b/tools/protovalidate-conformance/internal/cases/cases_map.go index a428e849..d482b8ed 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_map.go +++ b/tools/protovalidate-conformance/internal/cases/cases_map.go @@ -40,7 +40,8 @@ func mapSuite() suites.Suite { Message: &cases.MapMin{Val: map[int32]float32{1: 2}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), ConstraintId: proto.String("map.min_pairs"), Message: proto.String("map must be at least 2 entries"), }, @@ -58,7 +59,8 @@ func mapSuite() suites.Suite { Message: &cases.MapMax{Val: map[int64]float64{1: 2, 3: 4, 5: 6, 7: 8}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.max_pairs"), ConstraintId: proto.String("map.max_pairs"), Message: proto.String("map must be at most 3 entries"), }, @@ -80,7 +82,8 @@ func mapSuite() suites.Suite { Message: &cases.MapMinMax{Val: map[string]bool{}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), ConstraintId: proto.String("map.min_pairs"), Message: proto.String("map must be at least 2 entries"), }, @@ -90,7 +93,8 @@ func mapSuite() suites.Suite { Message: &cases.MapMinMax{Val: map[string]bool{"a": true, "b": false, "c": true, "d": false, "e": true}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.max_pairs"), ConstraintId: proto.String("map.max_pairs"), Message: proto.String("map must be at most 4 entries"), }, @@ -104,7 +108,8 @@ func mapSuite() suites.Suite { Message: &cases.MapExact{Val: map[uint64]string{1: "a", 2: "b"}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.min_pairs"), ConstraintId: proto.String("map.min_pairs"), Message: proto.String("map must be at least 3 entries"), }, @@ -114,7 +119,8 @@ func mapSuite() suites.Suite { Message: &cases.MapExact{Val: map[uint64]string{1: "a", 2: "b", 3: "c", 4: "d"}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.max_pairs"), ConstraintId: proto.String("map.max_pairs"), Message: proto.String("map must be at most 3 entries"), }, @@ -136,7 +142,8 @@ func mapSuite() suites.Suite { Message: &cases.MapKeys{Val: map[int64]string{1: "a"}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("map.keys.sint64.lt"), ConstraintId: proto.String("sint64.lt"), Message: proto.String("value must be less than 0"), ForKey: proto.Bool(true), @@ -147,7 +154,8 @@ func mapSuite() suites.Suite { Message: &cases.MapKeysPattern{Val: map[string]string{"A": "a", "!@#$%^&*()": "b"}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[\"!@#$%^&*()\"]"), + Field: results.FieldPath("val[\"!@#$%^&*()\"]"), + Rule: results.FieldPath("map.keys.string.pattern"), ConstraintId: proto.String("string.pattern"), Message: proto.String("value does not match regex pattern `(?i)^[a-z0-9]+$`"), ForKey: proto.Bool(true), @@ -170,12 +178,14 @@ func mapSuite() suites.Suite { Message: &cases.MapValues{Val: map[string]string{"a": "A", "b": "B"}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[\"a\"]"), + Field: results.FieldPath("val[\"a\"]"), + Rule: results.FieldPath("map.values.string.min_len"), ConstraintId: proto.String("string.min_len"), Message: proto.String("value length must be at least 3 characters"), }, &validate.Violation{ - FieldPath: proto.String("val[\"b\"]"), + Field: results.FieldPath("val[\"b\"]"), + Rule: results.FieldPath("map.values.string.min_len"), ConstraintId: proto.String("string.min_len"), Message: proto.String("value length must be at least 3 characters"), }, @@ -185,7 +195,8 @@ func mapSuite() suites.Suite { Message: &cases.MapValuesPattern{Val: map[string]string{"a": "A", "b": "!@#$%^&*()"}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[\"b\"]"), + Field: results.FieldPath("val[\"b\"]"), + Rule: results.FieldPath("map.values.string.pattern"), ConstraintId: proto.String("string.pattern"), Message: proto.String("value does not match regex pattern `(?i)^[a-z0-9]+$`"), }, @@ -199,7 +210,8 @@ func mapSuite() suites.Suite { Message: &cases.MapRecursive{Val: map[uint32]*cases.MapRecursive_Msg{1: {}}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1].val"), + Field: results.FieldPath("val[1].val"), + Rule: results.FieldPath("string.min_len"), ConstraintId: proto.String("string.min_len"), Message: proto.String("value length must be at least 3 characters"), }, diff --git a/tools/protovalidate-conformance/internal/cases/cases_message.go b/tools/protovalidate-conformance/internal/cases/cases_message.go index f640767b..0bc83753 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_message.go +++ b/tools/protovalidate-conformance/internal/cases/cases_message.go @@ -53,7 +53,8 @@ func messageSuite() suites.Suite { Message: &cases.Message{Val: &cases.TestMsg{}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val.const"), + Field: results.FieldPath("val.const"), + Rule: results.FieldPath("string.const"), ConstraintId: proto.String("string.const"), Message: proto.String("value must equal `foo`"), }, @@ -63,7 +64,8 @@ func messageSuite() suites.Suite { Message: &cases.Message{Val: &cases.TestMsg{Const: "foo", Nested: &cases.TestMsg{}}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val.nested.const"), + Field: results.FieldPath("val.nested.const"), + Rule: results.FieldPath("string.const"), ConstraintId: proto.String("string.const"), Message: proto.String("value must equal `foo`"), }, @@ -85,7 +87,8 @@ func messageSuite() suites.Suite { Message: &cases.MessageRequired{}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), ConstraintId: proto.String("required"), Message: proto.String("value is required"), }, @@ -95,12 +98,13 @@ func messageSuite() suites.Suite { Message: &cases.MessageRequiredOneof{}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("one"), + Field: results.FieldPath("one"), ConstraintId: proto.String("required"), Message: proto.String("exactly one field is required in oneof"), }, &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), ConstraintId: proto.String("required"), Message: proto.String("value is required"), }, @@ -114,7 +118,8 @@ func messageSuite() suites.Suite { Message: &cases.MessageRequiredButOptional{}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), ConstraintId: proto.String("required"), Message: proto.String("value is required"), }, @@ -132,7 +137,8 @@ func messageSuite() suites.Suite { Message: &cases.MessageCrossPackage{Val: &other_package.Embed{}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val.val"), + Field: results.FieldPath("val.val"), + Rule: results.FieldPath("int64.gt"), ConstraintId: proto.String("int64.gt"), Message: proto.String("value must be greater than 0"), }, @@ -142,7 +148,8 @@ func messageSuite() suites.Suite { Message: &cases.MessageCrossPackage{Val: &other_package.Embed{Val: -1}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val.val"), + Field: results.FieldPath("val.val"), + Rule: results.FieldPath("int64.gt"), ConstraintId: proto.String("int64.gt"), Message: proto.String("value must be greater than 0"), }, diff --git a/tools/protovalidate-conformance/internal/cases/cases_nested.go b/tools/protovalidate-conformance/internal/cases/cases_nested.go index 33a15219..74c2af76 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_nested.go +++ b/tools/protovalidate-conformance/internal/cases/cases_nested.go @@ -43,7 +43,8 @@ func nestedSuite() suites.Suite { }, }, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("two.three.uuid"), + Field: results.FieldPath("two.three.uuid"), + Rule: results.FieldPath("string.uuid"), ConstraintId: proto.String("string.uuid"), }), }, diff --git a/tools/protovalidate-conformance/internal/cases/cases_oneof.go b/tools/protovalidate-conformance/internal/cases/cases_oneof.go index 5006c9cd..2cc843ef 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_oneof.go +++ b/tools/protovalidate-conformance/internal/cases/cases_oneof.go @@ -49,16 +49,28 @@ func oneofSuite() suites.Suite { Expected: results.Success(true), }, "field/X/invalid": { - Message: &cases.Oneof{O: &cases.Oneof_X{X: "fizzbuzz"}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("x"), ConstraintId: proto.String("string.prefix")}), + Message: &cases.Oneof{O: &cases.Oneof_X{X: "fizzbuzz"}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("x"), + Rule: results.FieldPath("string.prefix"), + ConstraintId: proto.String("string.prefix"), + }), }, "field/Y/invalid": { - Message: &cases.Oneof{O: &cases.Oneof_Y{Y: -1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("y"), ConstraintId: proto.String("int32.gt")}), + Message: &cases.Oneof{O: &cases.Oneof_Y{Y: -1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("y"), + Rule: results.FieldPath("int32.gt"), + ConstraintId: proto.String("int32.gt"), + }), }, "filed/Z/invalid": { - Message: &cases.Oneof{O: &cases.Oneof_Z{Z: &cases.TestOneofMsg{}}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("z.val"), ConstraintId: proto.String("bool.const")}), + Message: &cases.Oneof{O: &cases.Oneof_Z{Z: &cases.TestOneofMsg{}}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("z.val"), + Rule: results.FieldPath("bool.const"), + ConstraintId: proto.String("bool.const"), + }), }, "required/valid/empty": { Message: &cases.OneofRequired{O: &cases.OneofRequired_X{X: ""}}, @@ -69,8 +81,11 @@ func oneofSuite() suites.Suite { Expected: results.Success(true), }, "required/invalid": { - Message: &cases.OneofRequired{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("o"), ConstraintId: proto.String("required")}), + Message: &cases.OneofRequired{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("o"), + ConstraintId: proto.String("required"), + }), }, "required/required_field/valid/empty": { Message: &cases.OneofRequiredWithRequiredField{ @@ -88,13 +103,25 @@ func oneofSuite() suites.Suite { Message: &cases.OneofRequiredWithRequiredField{ O: &cases.OneofRequiredWithRequiredField_B{B: "foo"}, }, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("a"), ConstraintId: proto.String("required")}), + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("a"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "required/required_field/invalid": { Message: &cases.OneofRequiredWithRequiredField{}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("o"), ConstraintId: proto.String("required")}, - &validate.Violation{FieldPath: proto.String("a"), ConstraintId: proto.String("required")}), + &validate.Violation{ + Field: results.FieldPath("o"), + ConstraintId: proto.String("required"), + }, + &validate.Violation{ + Field: results.FieldPath("a"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }, + ), }, } } diff --git a/tools/protovalidate-conformance/internal/cases/cases_predefined.go b/tools/protovalidate-conformance/internal/cases/cases_predefined.go index abb56bde..5fa96135 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_predefined.go +++ b/tools/protovalidate-conformance/internal/cases/cases_predefined.go @@ -37,7 +37,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedFloatRuleProto2{Val: proto.Float32(-2.0)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.[buf.validate.conformance.cases.float_abs_range_proto2]"), ConstraintId: proto.String("float.abs_range.proto2"), Message: proto.String("float value is out of range"), }, @@ -51,7 +52,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedDoubleRuleProto2{Val: proto.Float64(-2.0)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.[buf.validate.conformance.cases.double_abs_range_proto2]"), ConstraintId: proto.String("double.abs_range.proto2"), Message: proto.String("double value is out of range"), }, @@ -65,7 +67,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedInt32RuleProto2{Val: proto.Int32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.[buf.validate.conformance.cases.int32_abs_in_proto2]"), ConstraintId: proto.String("int32.abs_in.proto2"), Message: proto.String("value must be in absolute value of list"), }, @@ -79,7 +82,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedInt64RuleProto2{Val: proto.Int64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.[buf.validate.conformance.cases.int64_abs_in_proto2]"), ConstraintId: proto.String("int64.abs_in.proto2"), Message: proto.String("value must be in absolute value of list"), }, @@ -93,7 +97,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedUInt32RuleProto2{Val: proto.Uint32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.[buf.validate.conformance.cases.uint32_even_proto2]"), ConstraintId: proto.String("uint32.even.proto2"), Message: proto.String("uint32 value is not even"), }, @@ -107,7 +112,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedUInt64RuleProto2{Val: proto.Uint64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.[buf.validate.conformance.cases.uint64_even_proto2]"), ConstraintId: proto.String("uint64.even.proto2"), Message: proto.String("uint64 value is not even"), }, @@ -121,7 +127,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedSInt32RuleProto2{Val: proto.Int32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.[buf.validate.conformance.cases.sint32_even_proto2]"), ConstraintId: proto.String("sint32.even.proto2"), Message: proto.String("sint32 value is not even"), }, @@ -135,7 +142,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedSInt64RuleProto2{Val: proto.Int64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.[buf.validate.conformance.cases.sint64_even_proto2]"), ConstraintId: proto.String("sint64.even.proto2"), Message: proto.String("sint64 value is not even"), }, @@ -149,7 +157,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedFixed32RuleProto2{Val: proto.Uint32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.[buf.validate.conformance.cases.fixed32_even_proto2]"), ConstraintId: proto.String("fixed32.even.proto2"), Message: proto.String("fixed32 value is not even"), }, @@ -163,7 +172,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedFixed64RuleProto2{Val: proto.Uint64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.[buf.validate.conformance.cases.fixed64_even_proto2]"), ConstraintId: proto.String("fixed64.even.proto2"), Message: proto.String("fixed64 value is not even"), }, @@ -177,7 +187,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedSFixed32RuleProto2{Val: proto.Int32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.[buf.validate.conformance.cases.sfixed32_even_proto2]"), ConstraintId: proto.String("sfixed32.even.proto2"), Message: proto.String("sfixed32 value is not even"), }, @@ -191,7 +202,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedSFixed64RuleProto2{Val: proto.Int64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.[buf.validate.conformance.cases.sfixed64_even_proto2]"), ConstraintId: proto.String("sfixed64.even.proto2"), Message: proto.String("sfixed64 value is not even"), }, @@ -205,7 +217,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedBoolRuleProto2{Val: proto.Bool(true)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bool.[buf.validate.conformance.cases.bool_false_proto2]"), ConstraintId: proto.String("bool.false.proto2"), Message: proto.String("bool value is not false"), }, @@ -219,7 +232,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedStringRuleProto2{Val: proto.String("../invalid/path")}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.[buf.validate.conformance.cases.string_valid_path_proto2]"), ConstraintId: proto.String("string.valid_path.proto2"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -233,7 +247,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedBytesRuleProto2{Val: []byte("../invalid/path")}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.[buf.validate.conformance.cases.bytes_valid_path_proto2]"), ConstraintId: proto.String("bytes.valid_path.proto2"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -247,7 +262,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedEnumRuleProto2{Val: cases.PredefinedEnumRuleProto2_ENUM_PROTO2_ZERO_UNSPECIFIED.Enum()}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("enum.[buf.validate.conformance.cases.enum_non_zero_proto2]"), ConstraintId: proto.String("enum.non_zero.proto2"), Message: proto.String("enum value is not non-zero"), }, @@ -261,7 +277,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedRepeatedRuleProto2{Val: []uint64{1, 2, 3}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.[buf.validate.conformance.cases.repeated_at_least_five_proto2]"), ConstraintId: proto.String("repeated.at_least_five.proto2"), Message: proto.String("repeated field must have at least five values"), }, @@ -275,7 +292,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedDurationRuleProto2{Val: durationpb.New(15 * time.Second)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.[buf.validate.conformance.cases.duration_too_long_proto2]"), ConstraintId: proto.String("duration.too_long.proto2"), Message: proto.String("duration can't be longer than 10 seconds"), }, @@ -289,7 +307,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedTimestampRuleProto2{Val: timestamppb.New(time.Unix(1725415496, 0))}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.[buf.validate.conformance.cases.timestamp_in_range_proto2]"), ConstraintId: proto.String("timestamp.time_range.proto2"), Message: proto.String("timestamp out of range"), }, @@ -303,7 +322,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedFloatRuleProto2{Val: wrapperspb.Float(-2.0)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.[buf.validate.conformance.cases.float_abs_range_proto2]"), ConstraintId: proto.String("float.abs_range.proto2"), Message: proto.String("float value is out of range"), }, @@ -319,7 +339,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedDoubleRuleProto2{Val: wrapperspb.Double(-2.0)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.[buf.validate.conformance.cases.double_abs_range_proto2]"), ConstraintId: proto.String("double.abs_range.proto2"), Message: proto.String("double value is out of range"), }, @@ -333,7 +354,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedInt32RuleProto2{Val: wrapperspb.Int32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.[buf.validate.conformance.cases.int32_abs_in_proto2]"), ConstraintId: proto.String("int32.abs_in.proto2"), Message: proto.String("value must be in absolute value of list"), }, @@ -347,7 +369,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedInt64RuleProto2{Val: wrapperspb.Int64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.[buf.validate.conformance.cases.int64_abs_in_proto2]"), ConstraintId: proto.String("int64.abs_in.proto2"), Message: proto.String("value must be in absolute value of list"), }, @@ -361,7 +384,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedUInt32RuleProto2{Val: wrapperspb.UInt32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.[buf.validate.conformance.cases.uint32_even_proto2]"), ConstraintId: proto.String("uint32.even.proto2"), Message: proto.String("uint32 value is not even"), }, @@ -375,7 +399,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedUInt64RuleProto2{Val: wrapperspb.UInt64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.[buf.validate.conformance.cases.uint64_even_proto2]"), ConstraintId: proto.String("uint64.even.proto2"), Message: proto.String("uint64 value is not even"), }, @@ -389,7 +414,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedBoolRuleProto2{Val: wrapperspb.Bool(true)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bool.[buf.validate.conformance.cases.bool_false_proto2]"), ConstraintId: proto.String("bool.false.proto2"), Message: proto.String("bool value is not false"), }, @@ -403,7 +429,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedStringRuleProto2{Val: wrapperspb.String("../invalid/path")}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.[buf.validate.conformance.cases.string_valid_path_proto2]"), ConstraintId: proto.String("string.valid_path.proto2"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -417,7 +444,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedBytesRuleProto2{Val: wrapperspb.Bytes([]byte("../invalid/path"))}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.[buf.validate.conformance.cases.bytes_valid_path_proto2]"), ConstraintId: proto.String("bytes.valid_path.proto2"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -435,7 +463,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.float.[buf.validate.conformance.cases.float_abs_range_proto2]"), ConstraintId: proto.String("float.abs_range.proto2"), Message: proto.String("float value is out of range"), }, @@ -453,7 +482,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.double.[buf.validate.conformance.cases.double_abs_range_proto2]"), ConstraintId: proto.String("double.abs_range.proto2"), Message: proto.String("double value is out of range"), }, @@ -471,7 +501,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.int32.[buf.validate.conformance.cases.int32_abs_in_proto2]"), ConstraintId: proto.String("int32.abs_in.proto2"), Message: proto.String("value must be in absolute value of list"), }, @@ -489,7 +520,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.int64.[buf.validate.conformance.cases.int64_abs_in_proto2]"), ConstraintId: proto.String("int64.abs_in.proto2"), Message: proto.String("value must be in absolute value of list"), }, @@ -507,7 +539,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.uint32.[buf.validate.conformance.cases.uint32_even_proto2]"), ConstraintId: proto.String("uint32.even.proto2"), Message: proto.String("uint32 value is not even"), }, @@ -525,7 +558,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.uint64.[buf.validate.conformance.cases.uint64_even_proto2]"), ConstraintId: proto.String("uint64.even.proto2"), Message: proto.String("uint64 value is not even"), }, @@ -543,7 +577,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.bool.[buf.validate.conformance.cases.bool_false_proto2]"), ConstraintId: proto.String("bool.false.proto2"), Message: proto.String("bool value is not false"), }, @@ -561,7 +596,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.string.[buf.validate.conformance.cases.string_valid_path_proto2]"), ConstraintId: proto.String("string.valid_path.proto2"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -579,7 +615,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.bytes.[buf.validate.conformance.cases.bytes_valid_path_proto2]"), ConstraintId: proto.String("bytes.valid_path.proto2"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -603,27 +640,32 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("sint32.[buf.validate.conformance.cases.sint32_even_proto2]"), ConstraintId: proto.String("sint32.even.proto2"), Message: proto.String("sint32 value is not even"), }, &validate.Violation{ - FieldPath: proto.String("b.c"), + Field: results.FieldPath("b.c"), + Rule: results.FieldPath("sint32.[buf.validate.conformance.cases.sint32_even_proto2]"), ConstraintId: proto.String("sint32.even.proto2"), Message: proto.String("sint32 value is not even"), }, &validate.Violation{ - FieldPath: proto.String("b"), + Field: results.FieldPath("b"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("predefined_and_custom_rule_embedded_proto2"), Message: proto.String("b.c must be a multiple of 3"), }, &validate.Violation{ - FieldPath: proto.String("b.c"), + Field: results.FieldPath("b.c"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("predefined_and_custom_rule_nested_proto2"), Message: proto.String("c must be positive"), }, &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("predefined_and_custom_rule_scalar_proto2"), Message: proto.String("a must be greater than 24"), }, @@ -641,7 +683,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("sint32.lt"), ConstraintId: proto.String("sint32.lt"), Message: proto.String("value must be less than 28"), }, @@ -653,7 +696,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("sint32.[buf.validate.conformance.cases.sint32_even_proto2]"), ConstraintId: proto.String("sint32.even.proto2"), Message: proto.String("sint32 value is not even"), }, @@ -665,7 +709,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("standard_predefined_and_custom_rule_scalar_proto2"), Message: proto.String("a must be greater than 24"), }, @@ -679,7 +724,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedFloatRuleProto3{Val: -2.0}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.[buf.validate.conformance.cases.float_abs_range_proto2]"), ConstraintId: proto.String("float.abs_range.proto2"), Message: proto.String("float value is out of range"), }, @@ -693,7 +739,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedDoubleRuleProto3{Val: -2.0}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.[buf.validate.conformance.cases.double_abs_range_proto2]"), ConstraintId: proto.String("double.abs_range.proto2"), Message: proto.String("double value is out of range"), }, @@ -707,7 +754,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedInt32RuleProto3{Val: 3}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.[buf.validate.conformance.cases.int32_abs_in_proto2]"), ConstraintId: proto.String("int32.abs_in.proto2"), Message: proto.String("value must be in absolute value of list"), }, @@ -721,7 +769,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedInt64RuleProto3{Val: 3}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.[buf.validate.conformance.cases.int64_abs_in_edition_2023]"), ConstraintId: proto.String("int64.abs_in.edition_2023"), Message: proto.String("value must be in absolute value of list"), }, @@ -735,7 +784,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedUInt32RuleProto3{Val: 3}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.[buf.validate.conformance.cases.uint32_even_proto2]"), ConstraintId: proto.String("uint32.even.proto2"), Message: proto.String("uint32 value is not even"), }, @@ -749,7 +799,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedUInt64RuleProto3{Val: 3}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.[buf.validate.conformance.cases.uint64_even_proto2]"), ConstraintId: proto.String("uint64.even.proto2"), Message: proto.String("uint64 value is not even"), }, @@ -763,7 +814,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedSInt32RuleProto3{Val: 3}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.[buf.validate.conformance.cases.sint32_even_proto2]"), ConstraintId: proto.String("sint32.even.proto2"), Message: proto.String("sint32 value is not even"), }, @@ -777,7 +829,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedSInt64RuleProto3{Val: 3}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.[buf.validate.conformance.cases.sint64_even_proto2]"), ConstraintId: proto.String("sint64.even.proto2"), Message: proto.String("sint64 value is not even"), }, @@ -791,7 +844,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedFixed32RuleProto3{Val: 3}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.[buf.validate.conformance.cases.fixed32_even_proto2]"), ConstraintId: proto.String("fixed32.even.proto2"), Message: proto.String("fixed32 value is not even"), }, @@ -805,7 +859,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedFixed64RuleProto3{Val: 3}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.[buf.validate.conformance.cases.fixed64_even_proto2]"), ConstraintId: proto.String("fixed64.even.proto2"), Message: proto.String("fixed64 value is not even"), }, @@ -819,7 +874,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedSFixed32RuleProto3{Val: 3}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.[buf.validate.conformance.cases.sfixed32_even_proto2]"), ConstraintId: proto.String("sfixed32.even.proto2"), Message: proto.String("sfixed32 value is not even"), }, @@ -833,7 +889,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedSFixed64RuleProto3{Val: 3}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.[buf.validate.conformance.cases.sfixed64_even_proto2]"), ConstraintId: proto.String("sfixed64.even.proto2"), Message: proto.String("sfixed64 value is not even"), }, @@ -847,7 +904,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedBoolRuleProto3{Val: true}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bool.[buf.validate.conformance.cases.bool_false_proto2]"), ConstraintId: proto.String("bool.false.proto2"), Message: proto.String("bool value is not false"), }, @@ -861,7 +919,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedStringRuleProto3{Val: "../invalid/path"}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.[buf.validate.conformance.cases.string_valid_path_proto2]"), ConstraintId: proto.String("string.valid_path.proto2"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -875,7 +934,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedBytesRuleProto3{Val: []byte("../invalid/path")}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.[buf.validate.conformance.cases.bytes_valid_path_proto2]"), ConstraintId: proto.String("bytes.valid_path.proto2"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -889,7 +949,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedEnumRuleProto3{Val: cases.PredefinedEnumRuleProto3_ENUM_PROTO3_ZERO_UNSPECIFIED}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("enum.[buf.validate.conformance.cases.enum_non_zero_proto2]"), ConstraintId: proto.String("enum.non_zero.proto2"), Message: proto.String("enum value is not non-zero"), }, @@ -903,7 +964,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedRepeatedRuleProto3{Val: []uint64{1, 2, 3}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.[buf.validate.conformance.cases.repeated_at_least_five_proto2]"), ConstraintId: proto.String("repeated.at_least_five.proto2"), Message: proto.String("repeated field must have at least five values"), }, @@ -917,7 +979,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedMapRuleProto3{Val: map[uint64]uint64{1: 1, 2: 2, 3: 3}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.[buf.validate.conformance.cases.map_at_least_five_edition_2023]"), ConstraintId: proto.String("map.at_least_five.edition_2023"), Message: proto.String("map must have at least five pairs"), }, @@ -931,7 +994,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedDurationRuleProto3{Val: durationpb.New(15 * time.Second)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.[buf.validate.conformance.cases.duration_too_long_proto2]"), ConstraintId: proto.String("duration.too_long.proto2"), Message: proto.String("duration can't be longer than 10 seconds"), }, @@ -945,7 +1009,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedTimestampRuleProto3{Val: timestamppb.New(time.Unix(1725415496, 0))}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.[buf.validate.conformance.cases.timestamp_in_range_proto2]"), ConstraintId: proto.String("timestamp.time_range.proto2"), Message: proto.String("timestamp out of range"), }, @@ -959,7 +1024,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedFloatRuleProto3{Val: wrapperspb.Float(-2.0)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.[buf.validate.conformance.cases.float_abs_range_proto2]"), ConstraintId: proto.String("float.abs_range.proto2"), Message: proto.String("float value is out of range"), }, @@ -975,7 +1041,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedDoubleRuleProto3{Val: wrapperspb.Double(-2.0)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.[buf.validate.conformance.cases.double_abs_range_proto2]"), ConstraintId: proto.String("double.abs_range.proto2"), Message: proto.String("double value is out of range"), }, @@ -989,7 +1056,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedInt32RuleProto3{Val: wrapperspb.Int32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.[buf.validate.conformance.cases.int32_abs_in_proto2]"), ConstraintId: proto.String("int32.abs_in.proto2"), Message: proto.String("value must be in absolute value of list"), }, @@ -1003,7 +1071,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedInt64RuleProto3{Val: wrapperspb.Int64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.[buf.validate.conformance.cases.int64_abs_in_proto2]"), ConstraintId: proto.String("int64.abs_in.proto2"), Message: proto.String("value must be in absolute value of list"), }, @@ -1017,7 +1086,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedUInt32RuleProto3{Val: wrapperspb.UInt32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.[buf.validate.conformance.cases.uint32_even_proto2]"), ConstraintId: proto.String("uint32.even.proto2"), Message: proto.String("uint32 value is not even"), }, @@ -1031,7 +1101,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedUInt64RuleProto3{Val: wrapperspb.UInt64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.[buf.validate.conformance.cases.uint64_even_proto2]"), ConstraintId: proto.String("uint64.even.proto2"), Message: proto.String("uint64 value is not even"), }, @@ -1045,7 +1116,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedBoolRuleProto3{Val: wrapperspb.Bool(true)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bool.[buf.validate.conformance.cases.bool_false_proto2]"), ConstraintId: proto.String("bool.false.proto2"), Message: proto.String("bool value is not false"), }, @@ -1059,7 +1131,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedStringRuleProto3{Val: wrapperspb.String("../invalid/path")}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.[buf.validate.conformance.cases.string_valid_path_proto2]"), ConstraintId: proto.String("string.valid_path.proto2"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -1073,7 +1146,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedBytesRuleProto3{Val: wrapperspb.Bytes([]byte("../invalid/path"))}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.[buf.validate.conformance.cases.bytes_valid_path_proto2]"), ConstraintId: proto.String("bytes.valid_path.proto2"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -1091,7 +1165,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.float.[buf.validate.conformance.cases.float_abs_range_proto2]"), ConstraintId: proto.String("float.abs_range.proto2"), Message: proto.String("float value is out of range"), }, @@ -1109,7 +1184,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.double.[buf.validate.conformance.cases.double_abs_range_proto2]"), ConstraintId: proto.String("double.abs_range.proto2"), Message: proto.String("double value is out of range"), }, @@ -1127,7 +1203,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.int32.[buf.validate.conformance.cases.int32_abs_in_proto2]"), ConstraintId: proto.String("int32.abs_in.proto2"), Message: proto.String("value must be in absolute value of list"), }, @@ -1145,7 +1222,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.int64.[buf.validate.conformance.cases.int64_abs_in_proto2]"), ConstraintId: proto.String("int64.abs_in.proto2"), Message: proto.String("value must be in absolute value of list"), }, @@ -1163,7 +1241,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.uint32.[buf.validate.conformance.cases.uint32_even_proto2]"), ConstraintId: proto.String("uint32.even.proto2"), Message: proto.String("uint32 value is not even"), }, @@ -1181,7 +1260,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.uint64.[buf.validate.conformance.cases.uint64_even_proto2]"), ConstraintId: proto.String("uint64.even.proto2"), Message: proto.String("uint64 value is not even"), }, @@ -1199,7 +1279,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.bool.[buf.validate.conformance.cases.bool_false_proto2]"), ConstraintId: proto.String("bool.false.proto2"), Message: proto.String("bool value is not false"), }, @@ -1217,7 +1298,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.string.[buf.validate.conformance.cases.string_valid_path_proto2]"), ConstraintId: proto.String("string.valid_path.proto2"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -1235,7 +1317,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.bytes.[buf.validate.conformance.cases.bytes_valid_path_proto2]"), ConstraintId: proto.String("bytes.valid_path.proto2"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -1259,27 +1342,32 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("sint32.[buf.validate.conformance.cases.sint32_even_edition_2023]"), ConstraintId: proto.String("sint32.even.edition_2023"), Message: proto.String("sint32 value is not even"), }, &validate.Violation{ - FieldPath: proto.String("b.c"), + Field: results.FieldPath("b.c"), + Rule: results.FieldPath("sint32.[buf.validate.conformance.cases.sint32_even_edition_2023]"), ConstraintId: proto.String("sint32.even.edition_2023"), Message: proto.String("sint32 value is not even"), }, &validate.Violation{ - FieldPath: proto.String("b"), + Field: results.FieldPath("b"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("predefined_and_custom_rule_embedded_proto3"), Message: proto.String("b.c must be a multiple of 3"), }, &validate.Violation{ - FieldPath: proto.String("b.c"), + Field: results.FieldPath("b.c"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("predefined_and_custom_rule_nested_proto3"), Message: proto.String("c must be positive"), }, &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("predefined_and_custom_rule_scalar_proto3"), Message: proto.String("a must be greater than 24"), }, @@ -1297,7 +1385,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("sint32.lt"), ConstraintId: proto.String("sint32.lt"), Message: proto.String("value must be less than 28"), }, @@ -1309,7 +1398,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("sint32.[buf.validate.conformance.cases.sint32_even_proto2]"), ConstraintId: proto.String("sint32.even.proto2"), Message: proto.String("sint32 value is not even"), }, @@ -1321,7 +1411,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("standard_predefined_and_custom_rule_scalar_proto3"), Message: proto.String("a must be greater than 24"), }, @@ -1335,7 +1426,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedFloatRuleEdition2023{Val: proto.Float32(-2.0)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.[buf.validate.conformance.cases.float_abs_range_edition_2023]"), ConstraintId: proto.String("float.abs_range.edition_2023"), Message: proto.String("float value is out of range"), }, @@ -1349,7 +1441,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedDoubleRuleEdition2023{Val: proto.Float64(-2.0)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.[buf.validate.conformance.cases.double_abs_range_edition_2023]"), ConstraintId: proto.String("double.abs_range.edition_2023"), Message: proto.String("double value is out of range"), }, @@ -1363,7 +1456,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedInt32RuleEdition2023{Val: proto.Int32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.[buf.validate.conformance.cases.int32_abs_in_edition_2023]"), ConstraintId: proto.String("int32.abs_in.edition_2023"), Message: proto.String("value must be in absolute value of list"), }, @@ -1377,7 +1471,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedInt64RuleEdition2023{Val: proto.Int64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.[buf.validate.conformance.cases.int64_abs_in_edition_2023]"), ConstraintId: proto.String("int64.abs_in.edition_2023"), Message: proto.String("value must be in absolute value of list"), }, @@ -1391,7 +1486,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedUInt32RuleEdition2023{Val: proto.Uint32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.[buf.validate.conformance.cases.uint32_even_edition_2023]"), ConstraintId: proto.String("uint32.even.edition_2023"), Message: proto.String("uint32 value is not even"), }, @@ -1405,7 +1501,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedUInt64RuleEdition2023{Val: proto.Uint64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.[buf.validate.conformance.cases.uint64_even_edition_2023]"), ConstraintId: proto.String("uint64.even.edition_2023"), Message: proto.String("uint64 value is not even"), }, @@ -1419,7 +1516,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedSInt32RuleEdition2023{Val: proto.Int32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.[buf.validate.conformance.cases.sint32_even_edition_2023]"), ConstraintId: proto.String("sint32.even.edition_2023"), Message: proto.String("sint32 value is not even"), }, @@ -1433,7 +1531,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedSInt64RuleEdition2023{Val: proto.Int64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.[buf.validate.conformance.cases.sint64_even_edition_2023]"), ConstraintId: proto.String("sint64.even.edition_2023"), Message: proto.String("sint64 value is not even"), }, @@ -1447,7 +1546,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedFixed32RuleEdition2023{Val: proto.Uint32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed32.[buf.validate.conformance.cases.fixed32_even_edition_2023]"), ConstraintId: proto.String("fixed32.even.edition_2023"), Message: proto.String("fixed32 value is not even"), }, @@ -1461,7 +1561,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedFixed64RuleEdition2023{Val: proto.Uint64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("fixed64.[buf.validate.conformance.cases.fixed64_even_edition_2023]"), ConstraintId: proto.String("fixed64.even.edition_2023"), Message: proto.String("fixed64 value is not even"), }, @@ -1475,7 +1576,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedSFixed32RuleEdition2023{Val: proto.Int32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.[buf.validate.conformance.cases.sfixed32_even_edition_2023]"), ConstraintId: proto.String("sfixed32.even.edition_2023"), Message: proto.String("sfixed32 value is not even"), }, @@ -1489,7 +1591,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedSFixed64RuleEdition2023{Val: proto.Int64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.[buf.validate.conformance.cases.sfixed64_even_edition_2023]"), ConstraintId: proto.String("sfixed64.even.edition_2023"), Message: proto.String("sfixed64 value is not even"), }, @@ -1503,7 +1606,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedBoolRuleEdition2023{Val: proto.Bool(true)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bool.[buf.validate.conformance.cases.bool_false_edition_2023]"), ConstraintId: proto.String("bool.false.edition_2023"), Message: proto.String("bool value is not false"), }, @@ -1517,7 +1621,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedStringRuleEdition2023{Val: proto.String("../invalid/path")}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.[buf.validate.conformance.cases.string_valid_path_edition_2023]"), ConstraintId: proto.String("string.valid_path.edition_2023"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -1531,7 +1636,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedBytesRuleEdition2023{Val: []byte("../invalid/path")}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.[buf.validate.conformance.cases.bytes_valid_path_edition_2023]"), ConstraintId: proto.String("bytes.valid_path.edition_2023"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -1545,7 +1651,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedEnumRuleEdition2023{Val: cases.PredefinedEnumRuleEdition2023_ENUM_EDITION2023_ZERO_UNSPECIFIED.Enum()}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("enum.[buf.validate.conformance.cases.enum_non_zero_edition_2023]"), ConstraintId: proto.String("enum.non_zero.edition_2023"), Message: proto.String("enum value is not non-zero"), }, @@ -1559,7 +1666,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedRepeatedRuleEdition2023{Val: []uint64{1, 2, 3}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.[buf.validate.conformance.cases.repeated_at_least_five_edition_2023]"), ConstraintId: proto.String("repeated.at_least_five.edition_2023"), Message: proto.String("repeated field must have at least five values"), }, @@ -1573,7 +1681,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedMapRuleEdition2023{Val: map[uint64]uint64{1: 1, 2: 2, 3: 3}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("map.[buf.validate.conformance.cases.map_at_least_five_edition_2023]"), ConstraintId: proto.String("map.at_least_five.edition_2023"), Message: proto.String("map must have at least five pairs"), }, @@ -1587,7 +1696,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedDurationRuleEdition2023{Val: durationpb.New(15 * time.Second)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("duration.[buf.validate.conformance.cases.duration_too_long_edition_2023]"), ConstraintId: proto.String("duration.too_long.edition_2023"), Message: proto.String("duration can't be longer than 10 seconds"), }, @@ -1601,7 +1711,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedTimestampRuleEdition2023{Val: timestamppb.New(time.Unix(1725415496, 0))}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.[buf.validate.conformance.cases.timestamp_in_range_edition_2023]"), ConstraintId: proto.String("timestamp.time_range.edition_2023"), Message: proto.String("timestamp out of range"), }, @@ -1615,7 +1726,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedFloatRuleEdition2023{Val: wrapperspb.Float(-2.0)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.[buf.validate.conformance.cases.float_abs_range_edition_2023]"), ConstraintId: proto.String("float.abs_range.edition_2023"), Message: proto.String("float value is out of range"), }, @@ -1631,7 +1743,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedDoubleRuleEdition2023{Val: wrapperspb.Double(-2.0)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.[buf.validate.conformance.cases.double_abs_range_edition_2023]"), ConstraintId: proto.String("double.abs_range.edition_2023"), Message: proto.String("double value is out of range"), }, @@ -1645,7 +1758,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedInt32RuleEdition2023{Val: wrapperspb.Int32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.[buf.validate.conformance.cases.int32_abs_in_edition_2023]"), ConstraintId: proto.String("int32.abs_in.edition_2023"), Message: proto.String("value must be in absolute value of list"), }, @@ -1659,7 +1773,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedInt64RuleEdition2023{Val: wrapperspb.Int64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.[buf.validate.conformance.cases.int64_abs_in_edition_2023]"), ConstraintId: proto.String("int64.abs_in.edition_2023"), Message: proto.String("value must be in absolute value of list"), }, @@ -1673,7 +1788,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedUInt32RuleEdition2023{Val: wrapperspb.UInt32(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.[buf.validate.conformance.cases.uint32_even_edition_2023]"), ConstraintId: proto.String("uint32.even.edition_2023"), Message: proto.String("uint32 value is not even"), }, @@ -1687,7 +1803,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedUInt64RuleEdition2023{Val: wrapperspb.UInt64(3)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.[buf.validate.conformance.cases.uint64_even_edition_2023]"), ConstraintId: proto.String("uint64.even.edition_2023"), Message: proto.String("uint64 value is not even"), }, @@ -1701,7 +1818,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedBoolRuleEdition2023{Val: wrapperspb.Bool(true)}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bool.[buf.validate.conformance.cases.bool_false_edition_2023]"), ConstraintId: proto.String("bool.false.edition_2023"), Message: proto.String("bool value is not false"), }, @@ -1715,7 +1833,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedStringRuleEdition2023{Val: wrapperspb.String("../invalid/path")}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.[buf.validate.conformance.cases.string_valid_path_edition_2023]"), ConstraintId: proto.String("string.valid_path.edition_2023"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -1729,7 +1848,8 @@ func predefinedSuite() suites.Suite { Message: &cases.PredefinedWrappedBytesRuleEdition2023{Val: wrapperspb.Bytes([]byte("../invalid/path"))}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.[buf.validate.conformance.cases.bytes_valid_path_edition_2023]"), ConstraintId: proto.String("bytes.valid_path.edition_2023"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -1747,7 +1867,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.float.[buf.validate.conformance.cases.float_abs_range_edition_2023]"), ConstraintId: proto.String("float.abs_range.edition_2023"), Message: proto.String("float value is out of range"), }, @@ -1765,7 +1886,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.double.[buf.validate.conformance.cases.double_abs_range_edition_2023]"), ConstraintId: proto.String("double.abs_range.edition_2023"), Message: proto.String("double value is out of range"), }, @@ -1783,7 +1905,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.int32.[buf.validate.conformance.cases.int32_abs_in_edition_2023]"), ConstraintId: proto.String("int32.abs_in.edition_2023"), Message: proto.String("value must be in absolute value of list"), }, @@ -1801,7 +1924,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.int64.[buf.validate.conformance.cases.int64_abs_in_edition_2023]"), ConstraintId: proto.String("int64.abs_in.edition_2023"), Message: proto.String("value must be in absolute value of list"), }, @@ -1819,7 +1943,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.uint32.[buf.validate.conformance.cases.uint32_even_edition_2023]"), ConstraintId: proto.String("uint32.even.edition_2023"), Message: proto.String("uint32 value is not even"), }, @@ -1837,7 +1962,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.uint64.[buf.validate.conformance.cases.uint64_even_edition_2023]"), ConstraintId: proto.String("uint64.even.edition_2023"), Message: proto.String("uint64 value is not even"), }, @@ -1855,7 +1981,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.bool.[buf.validate.conformance.cases.bool_false_edition_2023]"), ConstraintId: proto.String("bool.false.edition_2023"), Message: proto.String("bool value is not false"), }, @@ -1873,7 +2000,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.string.[buf.validate.conformance.cases.string_valid_path_edition_2023]"), ConstraintId: proto.String("string.valid_path.edition_2023"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -1891,7 +2019,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.bytes.[buf.validate.conformance.cases.bytes_valid_path_edition_2023]"), ConstraintId: proto.String("bytes.valid_path.edition_2023"), Message: proto.String("not a valid path: `../invalid/path`"), }, @@ -1915,27 +2044,32 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("sint32.[buf.validate.conformance.cases.sint32_even_edition_2023]"), ConstraintId: proto.String("sint32.even.edition_2023"), Message: proto.String("sint32 value is not even"), }, &validate.Violation{ - FieldPath: proto.String("b.c"), + Field: results.FieldPath("b.c"), + Rule: results.FieldPath("sint32.[buf.validate.conformance.cases.sint32_even_edition_2023]"), ConstraintId: proto.String("sint32.even.edition_2023"), Message: proto.String("sint32 value is not even"), }, &validate.Violation{ - FieldPath: proto.String("b"), + Field: results.FieldPath("b"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("predefined_and_custom_rule_embedded_edition_2023"), Message: proto.String("b.c must be a multiple of 3"), }, &validate.Violation{ - FieldPath: proto.String("b.c"), + Field: results.FieldPath("b.c"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("predefined_and_custom_rule_nested_edition_2023"), Message: proto.String("c must be positive"), }, &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("predefined_and_custom_rule_scalar_edition_2023"), Message: proto.String("a must be greater than 24"), }, @@ -1953,7 +2087,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("sint32.lt"), ConstraintId: proto.String("sint32.lt"), Message: proto.String("value must be less than 28"), }, @@ -1965,7 +2100,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("sint32.[buf.validate.conformance.cases.sint32_even_edition_2023]"), ConstraintId: proto.String("sint32.even.edition_2023"), Message: proto.String("sint32 value is not even"), }, @@ -1977,7 +2113,8 @@ func predefinedSuite() suites.Suite { }, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("cel[0]"), ConstraintId: proto.String("standard_predefined_and_custom_rule_scalar_edition_2023"), Message: proto.String("a must be greater than 24"), }, diff --git a/tools/protovalidate-conformance/internal/cases/cases_repeated.go b/tools/protovalidate-conformance/internal/cases/cases_repeated.go index e6528f72..ff7aa14d 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_repeated.go +++ b/tools/protovalidate-conformance/internal/cases/cases_repeated.go @@ -47,7 +47,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedEmbedNone{Val: []*cases.Embed{{Val: -1}}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[0].val"), + Field: results.FieldPath("val[0].val"), + Rule: results.FieldPath("int64.gt"), ConstraintId: proto.String("int64.gt"), Message: proto.String("value must be greater than 0"), }, @@ -69,7 +70,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedEmbedCrossPackageNone{Val: []*other_package.Embed{{Val: -1}}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[0].val"), + Field: results.FieldPath("val[0].val"), + Rule: results.FieldPath("int64.gt"), ConstraintId: proto.String("int64.gt"), Message: proto.String("value must be greater than 0"), }, @@ -87,7 +89,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedMin{Val: []*cases.Embed{{Val: 1}}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), ConstraintId: proto.String("repeated.min_items"), Message: proto.String("value must contain at least 2 item(s)"), }, @@ -97,7 +100,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedMin{Val: []*cases.Embed{{Val: 1}, {Val: -1}}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1].val"), + Field: results.FieldPath("val[1].val"), + Rule: results.FieldPath("int64.gt"), ConstraintId: proto.String("int64.gt"), Message: proto.String("value must be greater than 0"), }, @@ -115,7 +119,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedMax{Val: []float64{1, 2, 3, 4}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.max_items"), ConstraintId: proto.String("repeated.max_items"), Message: proto.String("value must contain no more than 3 item(s)"), }, @@ -137,7 +142,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedMinMax{Val: []int32{}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), ConstraintId: proto.String("repeated.min_items"), Message: proto.String("value must contain at least 2 item(s)"), }, @@ -147,7 +153,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedMinMax{Val: []int32{1, 2, 3, 4, 5}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.max_items"), ConstraintId: proto.String("repeated.max_items"), Message: proto.String("value must contain no more than 4 item(s)"), }, @@ -161,7 +168,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedExact{Val: []uint32{1, 2}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), ConstraintId: proto.String("repeated.min_items"), Message: proto.String("value must contain at least 3 item(s)"), }, @@ -171,7 +179,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedExact{Val: []uint32{1, 2, 3, 4}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.max_items"), ConstraintId: proto.String("repeated.max_items"), Message: proto.String("value must contain no more than 3 item(s)"), }, @@ -193,7 +202,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedUnique{Val: []string{"foo", "bar", "foo", "baz"}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.unique"), ConstraintId: proto.String("repeated.unique"), }, ), @@ -210,12 +220,14 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedMultipleUnique{A: []string{"foo", "foo"}, B: []int32{1, 1}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("a"), + Field: results.FieldPath("a"), + Rule: results.FieldPath("repeated.unique"), ConstraintId: proto.String("repeated.unique"), Message: proto.String("repeated value must contain unique items"), }, &validate.Violation{ - FieldPath: proto.String("b"), + Field: results.FieldPath("b"), + Rule: results.FieldPath("repeated.unique"), ConstraintId: proto.String("repeated.unique"), Message: proto.String("repeated value must contain unique items"), }), @@ -236,7 +248,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedItemRule{Val: []float32{1, -2, 3}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.float.gt"), ConstraintId: proto.String("float.gt"), Message: proto.String("value must be greater than 0"), }, @@ -246,7 +259,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedItemPattern{Val: []string{"Alpha", "!@#$%^&*()"}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[1]"), + Field: results.FieldPath("val[1]"), + Rule: results.FieldPath("repeated.items.string.pattern"), ConstraintId: proto.String("string.pattern"), Message: proto.String("value does not match regex pattern `(?i)^[a-z0-9]+$`"), }, @@ -256,7 +270,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedItemIn{Val: []string{"baz"}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[0]"), + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.string.in"), ConstraintId: proto.String("string.in"), Message: proto.String(`value must be in list ["foo", "bar"]`), }, @@ -270,7 +285,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedItemNotIn{Val: []string{"foo"}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[0]"), + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.string.not_in"), ConstraintId: proto.String("string.not_in"), Message: proto.String("value must not be in list [\"foo\", \"bar\"]"), }, @@ -284,7 +300,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedEnumIn{Val: []cases.AnEnum{1}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[0]"), + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.enum.in"), ConstraintId: proto.String("enum.in"), Message: proto.String("value must be in list [0]"), }, @@ -298,7 +315,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedEnumNotIn{Val: []cases.AnEnum{0}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[0]"), + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.enum.not_in"), ConstraintId: proto.String("enum.not_in"), Message: proto.String("value must not be in list [0]"), }, @@ -312,7 +330,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedEmbeddedEnumIn{Val: []cases.RepeatedEmbeddedEnumIn_AnotherInEnum{1}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[0]"), + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.enum.in"), ConstraintId: proto.String("enum.in"), Message: proto.String("value must be in list [0]"), }, @@ -326,7 +345,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedEmbeddedEnumNotIn{Val: []cases.RepeatedEmbeddedEnumNotIn_AnotherNotInEnum{0}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[0]"), + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.enum.not_in"), ConstraintId: proto.String("enum.not_in"), Message: proto.String("value must not be in list [0]"), }, @@ -340,7 +360,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedAnyIn{Val: []*anypb.Any{{TypeUrl: "type.googleapis.com/google.protobuf.Timestamp"}}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[0]"), + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.any.in"), ConstraintId: proto.String("any.in"), Message: proto.String("type URL must be in the allow list"), }, @@ -354,7 +375,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedAnyNotIn{Val: []*anypb.Any{{TypeUrl: "type.googleapis.com/google.protobuf.Timestamp"}}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[0]"), + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.any.not_in"), ConstraintId: proto.String("any.not_in"), Message: proto.String("type URL must not be in the block list"), }, @@ -380,7 +402,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedMinAndItemLen{Val: []string{}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), ConstraintId: proto.String("repeated.min_items"), Message: proto.String("value must contain at least 1 item(s)"), }, @@ -390,7 +413,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedMinAndItemLen{Val: []string{"x"}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[0]"), + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.string.len"), ConstraintId: proto.String("string.len"), Message: proto.String("value length must be 3 characters"), }, @@ -404,7 +428,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedMinAndMaxItemLen{}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.min_items"), ConstraintId: proto.String("repeated.min_items"), Message: proto.String("value must contain at least 1 item(s)"), }, @@ -414,7 +439,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedMinAndMaxItemLen{Val: []string{"aaa", "bbb", "ccc", "ddd"}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("repeated.max_items"), ConstraintId: proto.String("repeated.max_items"), Message: proto.String("value must contain no more than 3 item(s)"), }, @@ -436,7 +462,8 @@ func repeatedSuite() suites.Suite { Message: &cases.RepeatedDuration{Val: []*durationpb.Duration{{Seconds: -1}}}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val[0]"), + Field: results.FieldPath("val[0]"), + Rule: results.FieldPath("repeated.items.duration.gte"), ConstraintId: proto.String("duration.gte"), Message: proto.String("value must be greater than or equal to 0.001s"), }, diff --git a/tools/protovalidate-conformance/internal/cases/cases_required.go b/tools/protovalidate-conformance/internal/cases/cases_required.go index fcf97f2d..e1317dc5 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_required.go +++ b/tools/protovalidate-conformance/internal/cases/cases_required.go @@ -33,8 +33,12 @@ func requiredSuite() suites.Suite { Expected: results.Success(true), }, "proto2/scalar/optional/unset": suites.Case{ - Message: &cases.RequiredProto2ScalarOptional{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto2ScalarOptional{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto2/scalar/optional_with_default/nonzero": suites.Case{ Message: &cases.RequiredProto2ScalarOptionalDefault{Val: proto.String("bar")}, @@ -49,8 +53,12 @@ func requiredSuite() suites.Suite { Expected: results.Success(true), }, "proto2/scalar/optional_with_default/unset": suites.Case{ - Message: &cases.RequiredProto2ScalarOptionalDefault{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto2ScalarOptionalDefault{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto2/scalar/required/nonzero": suites.Case{ Message: &cases.RequiredProto2ScalarRequired{Val: proto.String("foo")}, @@ -69,8 +77,12 @@ func requiredSuite() suites.Suite { Expected: results.Success(true), }, "proto2/message/unset": suites.Case{ - Message: &cases.RequiredProto2Message{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto2Message{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto2/oneof/nonzero": suites.Case{ Message: &cases.RequiredProto2Oneof{Val: &cases.RequiredProto2Oneof_A{A: "foo"}}, @@ -81,36 +93,56 @@ func requiredSuite() suites.Suite { Expected: results.Success(true), }, "proto2/oneof/other_member": suites.Case{ - Message: &cases.RequiredProto2Oneof{Val: &cases.RequiredProto2Oneof_B{B: "foo"}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("a"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto2Oneof{Val: &cases.RequiredProto2Oneof_B{B: "foo"}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("a"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto2/oneof/unset": suites.Case{ - Message: &cases.RequiredProto2Oneof{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("a"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto2Oneof{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("a"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto2/repeated/nonempty": suites.Case{ Message: &cases.RequiredProto2Repeated{Val: []string{"foo"}}, Expected: results.Success(true), }, "proto2/repeated/empty": suites.Case{ - Message: &cases.RequiredProto2Repeated{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto2Repeated{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto2/map/nonempty": suites.Case{ Message: &cases.RequiredProto2Map{Val: map[string]string{"foo": "bar"}}, Expected: results.Success(true), }, "proto2/map/empty": suites.Case{ - Message: &cases.RequiredProto2Map{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto2Map{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto3/scalar/nonzero": suites.Case{ Message: &cases.RequiredProto3Scalar{Val: "foo"}, Expected: results.Success(true), }, "proto3/scalar/zero": suites.Case{ - Message: &cases.RequiredProto3Scalar{Val: ""}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto3Scalar{Val: ""}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto3/scalar/optional/nonzero": suites.Case{ Message: &cases.RequiredProto3OptionalScalar{Val: proto.String("foo")}, @@ -121,8 +153,12 @@ func requiredSuite() suites.Suite { Expected: results.Success(true), }, "proto3/scalar/optional/unset": suites.Case{ - Message: &cases.RequiredProto3OptionalScalar{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto3OptionalScalar{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto3/message/nonzero": suites.Case{ Message: &cases.RequiredProto3Message{Val: &cases.RequiredProto3Message_Msg{Val: "foo"}}, @@ -133,8 +169,12 @@ func requiredSuite() suites.Suite { Expected: results.Success(true), }, "proto3/message/unset": suites.Case{ - Message: &cases.RequiredProto3Message{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto3Message{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto3/oneof/nonzero": suites.Case{ Message: &cases.RequiredProto3OneOf{Val: &cases.RequiredProto3OneOf_A{A: "foo"}}, @@ -145,28 +185,44 @@ func requiredSuite() suites.Suite { Expected: results.Success(true), }, "proto3/oneof/other_member": suites.Case{ - Message: &cases.RequiredProto3OneOf{Val: &cases.RequiredProto3OneOf_B{B: "foo"}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("a"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto3OneOf{Val: &cases.RequiredProto3OneOf_B{B: "foo"}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("a"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto3/oneof/unset": suites.Case{ - Message: &cases.RequiredProto3OneOf{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("a"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto3OneOf{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("a"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto3/repeated/nonempty": suites.Case{ Message: &cases.RequiredProto3Repeated{Val: []string{"foo"}}, Expected: results.Success(true), }, "proto3/repeated/empty": suites.Case{ - Message: &cases.RequiredProto3Repeated{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto3Repeated{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto3/map/nonempty": suites.Case{ Message: &cases.RequiredProto3Map{Val: map[string]string{"foo": "bar"}}, Expected: results.Success(true), }, "proto3/map/empty": suites.Case{ - Message: &cases.RequiredProto3Map{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredProto3Map{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto/2023/scalar/explicit_presence/nonzero": suites.Case{ Message: &cases.RequiredEditionsScalarExplicitPresence{Val: proto.String("foo")}, @@ -177,8 +233,12 @@ func requiredSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/explicit_presence/unset": suites.Case{ - Message: &cases.RequiredEditionsScalarExplicitPresence{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredEditionsScalarExplicitPresence{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto/2023/scalar/explicit_presence_with_default/nonzero": suites.Case{ Message: &cases.RequiredEditionsScalarExplicitPresenceDefault{Val: proto.String("bar")}, @@ -193,16 +253,24 @@ func requiredSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/scalar/explicit_presence_with_default/unset": suites.Case{ - Message: &cases.RequiredEditionsScalarExplicitPresenceDefault{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredEditionsScalarExplicitPresenceDefault{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto/2023/scalar/implicit_presence/nonzero": suites.Case{ Message: &cases.RequiredEditionsScalarImplicitPresence{Val: "foo"}, Expected: results.Success(true), }, "proto/2023/scalar/implicit_presence/zero": suites.Case{ - Message: &cases.RequiredEditionsScalarImplicitPresence{Val: ""}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredEditionsScalarImplicitPresence{Val: ""}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto/2023/scalar/legacy_required/nonzero": suites.Case{ Message: &cases.RequiredEditionsScalarLegacyRequired{Val: proto.String("foo")}, @@ -221,8 +289,12 @@ func requiredSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/message/explicit_presence/length_prefixed/unset": suites.Case{ - Message: &cases.RequiredEditionsMessageExplicitPresence{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredEditionsMessageExplicitPresence{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto/2023/message/explicit_presence/delimited/nonzero": suites.Case{ Message: &cases.RequiredEditionsMessageExplicitPresenceDelimited{Val: &cases.RequiredEditionsMessageExplicitPresenceDelimited_Msg{Val: proto.String("foo")}}, @@ -233,8 +305,12 @@ func requiredSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/message/explicit_presence/delimited/unset": suites.Case{ - Message: &cases.RequiredEditionsMessageExplicitPresenceDelimited{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredEditionsMessageExplicitPresenceDelimited{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto/2023/message/legacy_required/length_prefixed/nonzero": suites.Case{ Message: &cases.RequiredEditionsMessageLegacyRequired{Val: &cases.RequiredEditionsMessageLegacyRequired_Msg{Val: proto.String("foo")}}, @@ -261,36 +337,56 @@ func requiredSuite() suites.Suite { Expected: results.Success(true), }, "proto/2023/oneof/other_member": suites.Case{ - Message: &cases.RequiredEditionsOneof{Val: &cases.RequiredEditionsOneof_B{B: "foo"}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("a"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredEditionsOneof{Val: &cases.RequiredEditionsOneof_B{B: "foo"}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("a"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto/2023/oneof/unset": suites.Case{ - Message: &cases.RequiredEditionsOneof{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("a"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredEditionsOneof{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("a"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto/2023/repeated/compact/nonempty": suites.Case{ Message: &cases.RequiredEditionsRepeated{Val: []string{"foo"}}, Expected: results.Success(true), }, "proto/2023/repeated/compact/empty": suites.Case{ - Message: &cases.RequiredEditionsRepeated{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredEditionsRepeated{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto/2023/repeated/expanded/nonempty": suites.Case{ Message: &cases.RequiredEditionsRepeatedExpanded{Val: []string{"foo"}}, Expected: results.Success(true), }, "proto/2023/repeated/expanded/empty": suites.Case{ - Message: &cases.RequiredEditionsRepeatedExpanded{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredEditionsRepeatedExpanded{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "proto/2023/map/nonempty": suites.Case{ Message: &cases.RequiredEditionsMap{Val: map[string]string{"foo": "bar"}}, Expected: results.Success(true), }, "proto/2023/map/empty": suites.Case{ - Message: &cases.RequiredEditionsMap{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.RequiredEditionsMap{}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, } } diff --git a/tools/protovalidate-conformance/internal/cases/cases_sfixed32.go b/tools/protovalidate-conformance/internal/cases/cases_sfixed32.go index e6a30bc4..294b2a4c 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_sfixed32.go +++ b/tools/protovalidate-conformance/internal/cases/cases_sfixed32.go @@ -36,7 +36,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32Const{Val: 2}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.const"), ConstraintId: proto.String("sfixed32.const"), Message: proto.String("value must equal 1"), }, @@ -50,7 +51,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32In{Val: 5}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.in"), ConstraintId: proto.String("sfixed32.in"), Message: proto.String("value must be in list [2, 3]"), }, @@ -64,7 +66,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32NotIn{Val: 0}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.not_in"), ConstraintId: proto.String("sfixed32.not_in"), Message: proto.String("value must not be in list [0]"), }, @@ -78,7 +81,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32LT{Val: 0}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.lt"), ConstraintId: proto.String("sfixed32.lt"), Message: proto.String("value must be less than 0"), }, @@ -88,7 +92,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32LT{Val: 1}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.lt"), ConstraintId: proto.String("sfixed32.lt"), Message: proto.String("value must be less than 0"), }, @@ -106,7 +111,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32LTE{Val: 65}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.lte"), ConstraintId: proto.String("sfixed32.lte"), Message: proto.String("value must be less than or equal to 64"), }, @@ -120,7 +126,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32GT{Val: 16}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.gt"), ConstraintId: proto.String("sfixed32.gt"), Message: proto.String("value must be greater than 16"), }, @@ -130,7 +137,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32GT{Val: 15}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.gt"), ConstraintId: proto.String("sfixed32.gt"), Message: proto.String("value must be greater than 16"), }, @@ -148,7 +156,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32GTE{Val: 7}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.gte"), ConstraintId: proto.String("sfixed32.gte"), Message: proto.String("value must be greater than or equal to 8"), }, @@ -162,7 +171,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32GTLT{Val: 11}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.gt"), ConstraintId: proto.String("sfixed32.gt_lt"), Message: proto.String("value must be greater than 0 and less than 10"), }, @@ -172,7 +182,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32GTLT{Val: -1}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.gt"), ConstraintId: proto.String("sfixed32.gt_lt"), Message: proto.String("value must be greater than 0 and less than 10"), }, @@ -182,7 +193,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32GTLT{Val: 10}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.gt"), ConstraintId: proto.String("sfixed32.gt_lt"), Message: proto.String("value must be greater than 0 and less than 10"), }, @@ -192,7 +204,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32GTLT{Val: 0}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.gt"), ConstraintId: proto.String("sfixed32.gt_lt"), Message: proto.String("value must be greater than 0 and less than 10"), }, @@ -210,7 +223,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32ExLTGT{Val: 5}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.gt"), ConstraintId: proto.String("sfixed32.gt_lt_exclusive"), Message: proto.String("value must be greater than 10 or less than 0"), }, @@ -220,7 +234,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32ExLTGT{Val: 10}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.gt"), ConstraintId: proto.String("sfixed32.gt_lt_exclusive"), Message: proto.String("value must be greater than 10 or less than 0"), }, @@ -230,7 +245,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32ExLTGT{Val: 0}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.gt"), ConstraintId: proto.String("sfixed32.gt_lt_exclusive"), Message: proto.String("value must be greater than 10 or less than 0"), }, @@ -252,7 +268,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32GTELTE{Val: 300}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.gte"), ConstraintId: proto.String("sfixed32.gte_lte"), Message: proto.String("value must be greater than or equal to 128 and less than or equal to 256"), }, @@ -262,7 +279,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32GTELTE{Val: 100}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.gte"), ConstraintId: proto.String("sfixed32.gte_lte"), Message: proto.String("value must be greater than or equal to 128 and less than or equal to 256"), }, @@ -288,7 +306,8 @@ func sfixed32Suite() suites.Suite { Message: &cases.SFixed32ExGTELTE{Val: 200}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed32.gte"), ConstraintId: proto.String("sfixed32.gte_lte_exclusive"), Message: proto.String("value must be greater than or equal to 256 or less than or equal to 128"), }, diff --git a/tools/protovalidate-conformance/internal/cases/cases_sfixed64.go b/tools/protovalidate-conformance/internal/cases/cases_sfixed64.go index 800df010..7992a1d9 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_sfixed64.go +++ b/tools/protovalidate-conformance/internal/cases/cases_sfixed64.go @@ -36,7 +36,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64Const{Val: 2}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.const"), ConstraintId: proto.String("sfixed64.const"), Message: proto.String("value must equal 1"), }, @@ -50,7 +51,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64In{Val: 5}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.in"), ConstraintId: proto.String("sfixed64.in"), Message: proto.String("value must be in list [2, 3]"), }, @@ -64,7 +66,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64NotIn{Val: 0}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.not_in"), ConstraintId: proto.String("sfixed64.not_in"), Message: proto.String("value must not be in list [0]"), }, @@ -78,7 +81,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64LT{Val: 0}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.lt"), ConstraintId: proto.String("sfixed64.lt"), Message: proto.String("value must be less than 0"), }, @@ -88,7 +92,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64LT{Val: 1}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.lt"), ConstraintId: proto.String("sfixed64.lt"), Message: proto.String("value must be less than 0"), }, @@ -106,7 +111,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64LTE{Val: 65}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.lte"), ConstraintId: proto.String("sfixed64.lte"), Message: proto.String("value must be less than or equal to 64"), }, @@ -120,7 +126,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64GT{Val: 16}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.gt"), ConstraintId: proto.String("sfixed64.gt"), Message: proto.String("value must be greater than 16"), }, @@ -130,7 +137,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64GT{Val: 15}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.gt"), ConstraintId: proto.String("sfixed64.gt"), Message: proto.String("value must be greater than 16"), }, @@ -148,7 +156,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64GTE{Val: 7}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.gte"), ConstraintId: proto.String("sfixed64.gte"), Message: proto.String("value must be greater than or equal to 8"), }, @@ -162,7 +171,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64GTLT{Val: 11}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.gt"), ConstraintId: proto.String("sfixed64.gt_lt"), Message: proto.String("value must be greater than 0 and less than 10"), }, @@ -172,7 +182,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64GTLT{Val: -1}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.gt"), ConstraintId: proto.String("sfixed64.gt_lt"), Message: proto.String("value must be greater than 0 and less than 10"), }, @@ -182,7 +193,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64GTLT{Val: 10}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.gt"), ConstraintId: proto.String("sfixed64.gt_lt"), Message: proto.String("value must be greater than 0 and less than 10"), }, @@ -192,7 +204,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64GTLT{Val: 0}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.gt"), ConstraintId: proto.String("sfixed64.gt_lt"), Message: proto.String("value must be greater than 0 and less than 10"), }, @@ -210,7 +223,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64ExLTGT{Val: 5}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.gt"), ConstraintId: proto.String("sfixed64.gt_lt_exclusive"), Message: proto.String("value must be greater than 10 or less than 0"), }, @@ -220,7 +234,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64ExLTGT{Val: 10}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.gt"), ConstraintId: proto.String("sfixed64.gt_lt_exclusive"), Message: proto.String("value must be greater than 10 or less than 0"), }, @@ -230,7 +245,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64ExLTGT{Val: 0}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.gt"), ConstraintId: proto.String("sfixed64.gt_lt_exclusive"), Message: proto.String("value must be greater than 10 or less than 0"), }, @@ -252,7 +268,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64GTELTE{Val: 300}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.gte"), ConstraintId: proto.String("sfixed64.gte_lte"), Message: proto.String("value must be greater than or equal to 128 and less than or equal to 256"), }, @@ -262,7 +279,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64GTELTE{Val: 100}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.gte"), ConstraintId: proto.String("sfixed64.gte_lte"), Message: proto.String("value must be greater than or equal to 128 and less than or equal to 256"), }, @@ -288,7 +306,8 @@ func sfixed64Suite() suites.Suite { Message: &cases.SFixed64ExGTELTE{Val: 200}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("sfixed64.gte"), ConstraintId: proto.String("sfixed64.gte_lte_exclusive"), Message: proto.String("value must be greater than or equal to 256 or less than or equal to 128"), }, diff --git a/tools/protovalidate-conformance/internal/cases/cases_sint32.go b/tools/protovalidate-conformance/internal/cases/cases_sint32.go index 3873ddc9..a8fc6628 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_sint32.go +++ b/tools/protovalidate-conformance/internal/cases/cases_sint32.go @@ -35,7 +35,12 @@ func sint32Suite() suites.Suite { "const/invalid": { Message: &cases.SInt32Const{Val: 2}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.const"), + ConstraintId: proto.String("sint32.const"), + }, + ), }, "in/valid": { Message: &cases.SInt32In{Val: 3}, @@ -44,7 +49,12 @@ func sint32Suite() suites.Suite { "in/invalid": { Message: &cases.SInt32In{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.in"), + ConstraintId: proto.String("sint32.in"), + }, + ), }, "not_in/valid": { Message: &cases.SInt32NotIn{Val: 1}, @@ -53,7 +63,12 @@ func sint32Suite() suites.Suite { "not_in/invalid": { Message: &cases.SInt32NotIn{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.not_in"), + ConstraintId: proto.String("sint32.not_in"), + }, + ), }, "lt/valid/less": { Message: &cases.SInt32LT{Val: -1}, @@ -62,12 +77,22 @@ func sint32Suite() suites.Suite { "lt/invalid/equal": { Message: &cases.SInt32LT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.lt"), + ConstraintId: proto.String("sint32.lt"), + }, + ), }, "lt/invalid/greater": { Message: &cases.SInt32LT{Val: 1}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.lt"), + ConstraintId: proto.String("sint32.lt"), + }, + ), }, "lte/valid/less": { Message: &cases.SInt32LTE{Val: 63}, @@ -80,7 +105,12 @@ func sint32Suite() suites.Suite { "lte/invalid/greater": { Message: &cases.SInt32LTE{Val: 65}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.lte"), + ConstraintId: proto.String("sint32.lte"), + }, + ), }, "gt/valid/greater": { Message: &cases.SInt32GT{Val: 17}, @@ -89,12 +119,22 @@ func sint32Suite() suites.Suite { "gt/invalid/equal": { Message: &cases.SInt32GT{Val: 16}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gt"), + ConstraintId: proto.String("sint32.gt"), + }, + ), }, "gt/invalid/less": { Message: &cases.SInt32GT{Val: 15}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gt"), + ConstraintId: proto.String("sint32.gt"), + }, + ), }, "gte/valid/greater": { Message: &cases.SInt32GTE{Val: 9}, @@ -107,7 +147,12 @@ func sint32Suite() suites.Suite { "gte/invalid/less": { Message: &cases.SInt32GTE{Val: 7}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gte"), + ConstraintId: proto.String("sint32.gte"), + }, + ), }, "gt_lt/inclusive/valid/within": { Message: &cases.SInt32GTLT{Val: 5}, @@ -116,22 +161,42 @@ func sint32Suite() suites.Suite { "gt_lt/inclusive/invalid/above": { Message: &cases.SInt32GTLT{Val: 11}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gt"), + ConstraintId: proto.String("sint32.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/below": { Message: &cases.SInt32GTLT{Val: -1}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gt"), + ConstraintId: proto.String("sint32.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/max": { Message: &cases.SInt32GTLT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gt"), + ConstraintId: proto.String("sint32.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/min": { Message: &cases.SInt32GTLT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gt"), + ConstraintId: proto.String("sint32.gt_lt"), + }, + ), }, "gt_lt/exclusive/valid/above": { Message: &cases.SInt32ExLTGT{Val: 11}, @@ -144,17 +209,32 @@ func sint32Suite() suites.Suite { "gt_lt/exclusive/invalid/within": { Message: &cases.SInt32ExLTGT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gt"), + ConstraintId: proto.String("sint32.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/max": { Message: &cases.SInt32ExLTGT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gt"), + ConstraintId: proto.String("sint32.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/min": { Message: &cases.SInt32ExLTGT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gt"), + ConstraintId: proto.String("sint32.gt_lt_exclusive"), + }, + ), }, "gte_lte/inclusive/valid/within": { Message: &cases.SInt32GTELTE{Val: 200}, @@ -171,12 +251,22 @@ func sint32Suite() suites.Suite { "gte_lte/inclusive/invalid/above": { Message: &cases.SInt32GTELTE{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gte"), + ConstraintId: proto.String("sint32.gte_lte"), + }, + ), }, "gte_lte/inclusive/invalid/below": { Message: &cases.SInt32GTELTE{Val: 100}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gte"), + ConstraintId: proto.String("sint32.gte_lte"), + }, + ), }, "gte_lte/exclusive/valid/above": { Message: &cases.SInt32ExGTELTE{Val: 300}, @@ -197,7 +287,12 @@ func sint32Suite() suites.Suite { "gte_lte/exclusive/invalid/within": { Message: &cases.SInt32ExGTELTE{Val: 200}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gte_lte_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gte"), + ConstraintId: proto.String("sint32.gte_lte_exclusive"), + }, + ), }, "ignore_empty/valid/empty": { Message: &cases.SInt32Ignore{Val: 0}, @@ -210,7 +305,12 @@ func sint32Suite() suites.Suite { "ignore_empty/invalid/above": { Message: &cases.SInt32Ignore{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint32.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint32.gte"), + ConstraintId: proto.String("sint32.gte_lte"), + }, + ), }, "compilation/wrong_type": { Message: &cases.SInt32IncorrectType{Val: 123}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_sint64.go b/tools/protovalidate-conformance/internal/cases/cases_sint64.go index 277eeca6..9c8ef242 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_sint64.go +++ b/tools/protovalidate-conformance/internal/cases/cases_sint64.go @@ -35,7 +35,12 @@ func sint64Suite() suites.Suite { "const/invalid": { Message: &cases.SInt64Const{Val: 2}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.const"), + ConstraintId: proto.String("sint64.const"), + }, + ), }, "in/valid": { Message: &cases.SInt64In{Val: 3}, @@ -44,7 +49,12 @@ func sint64Suite() suites.Suite { "in/invalid": { Message: &cases.SInt64In{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.in"), + ConstraintId: proto.String("sint64.in"), + }, + ), }, "not_in/valid": { Message: &cases.SInt64NotIn{Val: 1}, @@ -53,7 +63,12 @@ func sint64Suite() suites.Suite { "not_in/invalid": { Message: &cases.SInt64NotIn{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.not_in"), + ConstraintId: proto.String("sint64.not_in"), + }, + ), }, "lt/valid/less": { Message: &cases.SInt64LT{Val: -1}, @@ -62,12 +77,22 @@ func sint64Suite() suites.Suite { "lt/invalid/equal": { Message: &cases.SInt64LT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.lt"), + ConstraintId: proto.String("sint64.lt"), + }, + ), }, "lt/invalid/greater": { Message: &cases.SInt64LT{Val: 1}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.lt"), + ConstraintId: proto.String("sint64.lt"), + }, + ), }, "lte/valid/less": { Message: &cases.SInt64LTE{Val: 63}, @@ -80,7 +105,12 @@ func sint64Suite() suites.Suite { "lte/invalid/greater": { Message: &cases.SInt64LTE{Val: 65}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.lte"), + ConstraintId: proto.String("sint64.lte"), + }, + ), }, "gt/valid/greater": { Message: &cases.SInt64GT{Val: 17}, @@ -89,12 +119,22 @@ func sint64Suite() suites.Suite { "gt/invalid/equal": { Message: &cases.SInt64GT{Val: 16}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gt"), + ConstraintId: proto.String("sint64.gt"), + }, + ), }, "gt/invalid/less": { Message: &cases.SInt64GT{Val: 15}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gt"), + ConstraintId: proto.String("sint64.gt"), + }, + ), }, "gte/valid/greater": { Message: &cases.SInt64GTE{Val: 9}, @@ -107,7 +147,12 @@ func sint64Suite() suites.Suite { "gte/invalid/less": { Message: &cases.SInt64GTE{Val: 7}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gte"), + ConstraintId: proto.String("sint64.gte"), + }, + ), }, "gt_lt/inclusive/valid/within": { Message: &cases.SInt64GTLT{Val: 5}, @@ -116,22 +161,42 @@ func sint64Suite() suites.Suite { "gt_lt/inclusive/invalid/above": { Message: &cases.SInt64GTLT{Val: 11}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gt"), + ConstraintId: proto.String("sint64.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/below": { Message: &cases.SInt64GTLT{Val: -1}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gt"), + ConstraintId: proto.String("sint64.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/max": { Message: &cases.SInt64GTLT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gt"), + ConstraintId: proto.String("sint64.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/min": { Message: &cases.SInt64GTLT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gt"), + ConstraintId: proto.String("sint64.gt_lt"), + }, + ), }, "gt_lt/exclusive/valid/above": { Message: &cases.SInt64ExLTGT{Val: 11}, @@ -144,17 +209,32 @@ func sint64Suite() suites.Suite { "gt_lt/exclusive/invalid/within": { Message: &cases.SInt64ExLTGT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gt"), + ConstraintId: proto.String("sint64.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/max": { Message: &cases.SInt64ExLTGT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gt"), + ConstraintId: proto.String("sint64.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/min": { Message: &cases.SInt64ExLTGT{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gt"), + ConstraintId: proto.String("sint64.gt_lt_exclusive"), + }, + ), }, "gte_lte/inclusive/valid/within": { Message: &cases.SInt64GTELTE{Val: 200}, @@ -171,12 +251,22 @@ func sint64Suite() suites.Suite { "gte_lte/inclusive/invalid/above": { Message: &cases.SInt64GTELTE{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gte"), + ConstraintId: proto.String("sint64.gte_lte"), + }, + ), }, "gte_lte/inclusive/invalid/below": { Message: &cases.SInt64GTELTE{Val: 100}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gte"), + ConstraintId: proto.String("sint64.gte_lte"), + }, + ), }, "gte_lte/exclusive/valid/above": { Message: &cases.SInt64ExGTELTE{Val: 300}, @@ -197,7 +287,12 @@ func sint64Suite() suites.Suite { "gte_lte/exclusive/invalid/within": { Message: &cases.SInt64ExGTELTE{Val: 200}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gte_lte_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gte"), + ConstraintId: proto.String("sint64.gte_lte_exclusive"), + }, + ), }, "ignore_empty/valid/empty": { Message: &cases.SInt64Ignore{Val: 0}, @@ -210,7 +305,12 @@ func sint64Suite() suites.Suite { "ignore_empty/invalid/above": { Message: &cases.SInt64Ignore{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("sint64.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("sint64.gte"), + ConstraintId: proto.String("sint64.gte_lte"), + }, + ), }, "compilation/wrong_type": { Message: &cases.SInt64IncorrectType{Val: 123}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_strings.go b/tools/protovalidate-conformance/internal/cases/cases_strings.go index 64a4551a..26b3d8c4 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_strings.go +++ b/tools/protovalidate-conformance/internal/cases/cases_strings.go @@ -35,7 +35,12 @@ func stringSuite() suites.Suite { "const/invalid": { Message: &cases.StringConst{Val: "bar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.const"), + ConstraintId: proto.String("string.const"), + }, + ), }, "in/valid": { Message: &cases.StringIn{Val: "baz"}, @@ -44,7 +49,12 @@ func stringSuite() suites.Suite { "in/invalid": { Message: &cases.StringIn{Val: "foo"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.in"), + ConstraintId: proto.String("string.in"), + }, + ), }, "not_in/valid": { Message: &cases.StringNotIn{Val: "bar"}, @@ -53,7 +63,12 @@ func stringSuite() suites.Suite { "not_in/invalid": { Message: &cases.StringNotIn{Val: "fizz"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.not_in"), + ConstraintId: proto.String("string.not_in"), + }, + ), }, "len/valid/ascii": { Message: &cases.StringLen{Val: "foo"}, @@ -70,13 +85,19 @@ func stringSuite() suites.Suite { "len/invalid": { Message: &cases.StringLen{Val: "fizz"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.len")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.len"), + ConstraintId: proto.String("string.len"), + }, + ), }, "len/invalid/emoji/composite": { Message: &cases.StringLen{Val: "👩🏽‍💻🧑🏾‍💻👨🏼‍💻"}, Expected: results.Violations( &validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.len"), ConstraintId: proto.String("string.len"), Message: proto.String("value length must be 3 characters"), }), @@ -92,7 +113,12 @@ func stringSuite() suites.Suite { "min_len/invalid/less": { Message: &cases.StringMinLen{Val: "pb"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.min_len")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.min_len"), + ConstraintId: proto.String("string.min_len"), + }, + ), }, "max_len/valid/equal": { Message: &cases.StringMaxLen{Val: "proto"}, @@ -105,7 +131,12 @@ func stringSuite() suites.Suite { "max_len/invalid/greater": { Message: &cases.StringMaxLen{Val: "validate"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.max_len")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.max_len"), + ConstraintId: proto.String("string.max_len"), + }, + ), }, "min_max_len/valid/within": { Message: &cases.StringMinMaxLen{Val: "quux"}, @@ -122,12 +153,22 @@ func stringSuite() suites.Suite { "min_max_len/invalid/less": { Message: &cases.StringMinMaxLen{Val: "pb"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.min_len")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.min_len"), + ConstraintId: proto.String("string.min_len"), + }, + ), }, "min_max_len/invalid/greater": { Message: &cases.StringMinMaxLen{Val: "validate"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.max_len")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.max_len"), + ConstraintId: proto.String("string.max_len"), + }, + ), }, "min_max_len/equal/valid": { Message: &cases.StringEqualMinMaxLen{Val: "proto"}, @@ -136,7 +177,12 @@ func stringSuite() suites.Suite { "min_max_len/equal/invalid": { Message: &cases.StringEqualMinMaxLen{Val: "validate"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.max_len")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.max_len"), + ConstraintId: proto.String("string.max_len"), + }, + ), }, "len_bytes/valid/ascii": { Message: &cases.StringLenBytes{Val: "fizz"}, @@ -153,7 +199,12 @@ func stringSuite() suites.Suite { "len_bytes/invalid": { Message: &cases.StringLenBytes{Val: "foo"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.len_bytes")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.len_bytes"), + ConstraintId: proto.String("string.len_bytes"), + }, + ), }, "min_bytes/valid/equal": { Message: &cases.StringMinBytes{Val: "fizz"}, @@ -166,7 +217,12 @@ func stringSuite() suites.Suite { "min_bytes/invalid/less": { Message: &cases.StringMinBytes{Val: "foo"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.min_bytes")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.min_bytes"), + ConstraintId: proto.String("string.min_bytes"), + }, + ), }, "max_bytes/valid/equal": { Message: &cases.StringMaxBytes{Val: "validate"}, @@ -179,7 +235,12 @@ func stringSuite() suites.Suite { "max_bytes/invalid/greater": { Message: &cases.StringMaxBytes{Val: "validation"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.max_bytes")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.max_bytes"), + ConstraintId: proto.String("string.max_bytes"), + }, + ), }, "min_max_bytes/valid/within": { Message: &cases.StringMinMaxBytes{Val: "quux"}, @@ -196,12 +257,22 @@ func stringSuite() suites.Suite { "min_max_bytes/invalid/less": { Message: &cases.StringMinMaxBytes{Val: "pb"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.min_bytes")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.min_bytes"), + ConstraintId: proto.String("string.min_bytes"), + }, + ), }, "min_max_bytes/invalid/greater": { Message: &cases.StringMinMaxBytes{Val: "validation"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.max_bytes")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.max_bytes"), + ConstraintId: proto.String("string.max_bytes"), + }, + ), }, "min_max_bytes/equal/valid": { Message: &cases.StringEqualMinMaxBytes{Val: "fizz"}, @@ -210,7 +281,12 @@ func stringSuite() suites.Suite { "min_max_bytes/equal/invalid": { Message: &cases.StringEqualMinMaxBytes{Val: "foo"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.min_bytes")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.min_bytes"), + ConstraintId: proto.String("string.min_bytes"), + }, + ), }, "pattern/valid": { Message: &cases.StringPattern{Val: "Foo123"}, @@ -219,7 +295,12 @@ func stringSuite() suites.Suite { "pattern/invalid": { Message: &cases.StringPattern{Val: "!#@$#$%"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.pattern")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.pattern"), + ConstraintId: proto.String("string.pattern"), + }, + ), }, "pattern/escapes/valid": { Message: &cases.StringPatternEscapes{Val: "* \\ x"}, @@ -228,7 +309,12 @@ func stringSuite() suites.Suite { "pattern/escapes/invalid": { Message: &cases.StringPatternEscapes{Val: "invalid"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.pattern")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.pattern"), + ConstraintId: proto.String("string.pattern"), + }, + ), }, "prefix/valid/exact": { Message: &cases.StringPrefix{Val: "foo"}, @@ -241,7 +327,12 @@ func stringSuite() suites.Suite { "prefix/invalid": { Message: &cases.StringPrefix{Val: "fizz"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.prefix")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.prefix"), + ConstraintId: proto.String("string.prefix"), + }, + ), }, "contains/valid/exact": { Message: &cases.StringContains{Val: "bar"}, @@ -262,7 +353,12 @@ func stringSuite() suites.Suite { "contains/invalid": { Message: &cases.StringContains{Val: "fizzbuzz"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.contains")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.contains"), + ConstraintId: proto.String("string.contains"), + }, + ), }, "not_contains/valid": { Message: &cases.StringNotContains{Val: "fizzbuzz"}, @@ -271,7 +367,12 @@ func stringSuite() suites.Suite { "not_contains/invalid": { Message: &cases.StringNotContains{Val: "foobarbaz"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.not_contains")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.not_contains"), + ConstraintId: proto.String("string.not_contains"), + }, + ), }, "suffix/valid/exact": { Message: &cases.StringSuffix{Val: "baz"}, @@ -284,7 +385,12 @@ func stringSuite() suites.Suite { "suffix/invalid": { Message: &cases.StringSuffix{Val: "bazbarfoo"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.suffix")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.suffix"), + ConstraintId: proto.String("string.suffix"), + }, + ), }, "email/valid/simple": { Message: &cases.StringEmail{Val: "foo@bar.com"}, @@ -293,7 +399,12 @@ func stringSuite() suites.Suite { "email/invalid/empty": { Message: &cases.StringEmail{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.email_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.email"), + ConstraintId: proto.String("string.email_empty"), + }, + ), }, "email/invalid/not_checked/empty": { Message: &cases.StringNotEmail{Val: ""}, @@ -306,59 +417,114 @@ func stringSuite() suites.Suite { "email/invalid/malformed": { Message: &cases.StringEmail{Val: "foobar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.email")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.email"), + ConstraintId: proto.String("string.email"), + }, + ), }, "email/invalid/local_segment_long": { Message: &cases.StringEmail{Val: "x0123456789012345678901234567890123456789012345678901234567890123456789@example.com"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.email")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.email"), + ConstraintId: proto.String("string.email"), + }, + ), }, "email/invalid/host_segment_long": { Message: &cases.StringEmail{Val: "foo@x0123456789012345678901234567890123456789012345678901234567890123456789.com"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.email")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.email"), + ConstraintId: proto.String("string.email"), + }, + ), }, "email/invalid/too_long": { Message: &cases.StringEmail{ Val: "x123456789.x123456789.x123456789.x123456789.x123456789@x123456789.x123456789.x123456789.x123456789.x123456789.x123456789.x123456789.x123456789.x123456789.x123456789.x123456789.x123456789.x123456789.x123456789.x123456789.x123456789.x123456789.x123456789.x123456789", }, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.email")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.email"), + ConstraintId: proto.String("string.email"), + }, + ), }, "email/invalid/bad_hostname": { Message: &cases.StringEmail{Val: "foo@-bar.com"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.email")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.email"), + ConstraintId: proto.String("string.email"), + }, + ), }, "email/invalid/only_dot_hostname": { Message: &cases.StringEmail{Val: "foo@."}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.email")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.email"), + ConstraintId: proto.String("string.email"), + }, + ), }, "email/invalid/white_spaces": { Message: &cases.StringEmail{Val: " foo@example.com "}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.email")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.email"), + ConstraintId: proto.String("string.email"), + }, + ), }, "email/invalid/trailing_white_space": { Message: &cases.StringEmail{Val: "foo@example.com "}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.email")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.email"), + ConstraintId: proto.String("string.email"), + }, + ), }, "email/invalid/leading_white_space": { Message: &cases.StringEmail{Val: " foo@example.com"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.email")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.email"), + ConstraintId: proto.String("string.email"), + }, + ), }, "email/invalid/angled_brackets": { Message: &cases.StringEmail{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.email")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.email"), + ConstraintId: proto.String("string.email"), + }, + ), }, "hostname/invalid/empty": { Message: &cases.StringHostname{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.hostname_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.hostname"), + ConstraintId: proto.String("string.hostname_empty"), + }, + ), }, "hostname/valid/lowercase": { Message: &cases.StringHostname{Val: "example.com"}, @@ -379,7 +545,12 @@ func stringSuite() suites.Suite { "hostname/invalid/malformed": { Message: &cases.StringHostname{Val: "@!#$%^&*&^%$#"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.hostname")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.hostname"), + ConstraintId: proto.String("string.hostname"), + }, + ), }, "hostname/invalid/not_checked/empty": { Message: &cases.StringNotHostname{Val: ""}, @@ -392,37 +563,72 @@ func stringSuite() suites.Suite { "hostname/invalid/underscore": { Message: &cases.StringHostname{Val: "foo_bar.com"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.hostname")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.hostname"), + ConstraintId: proto.String("string.hostname"), + }, + ), }, "hostname/invalid/long": { Message: &cases.StringHostname{Val: "x0123456789012345678901234567890123456789012345678901234567890123456789.com"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.hostname")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.hostname"), + ConstraintId: proto.String("string.hostname"), + }, + ), }, "hostname/invalid/trailing_hyphen": { Message: &cases.StringHostname{Val: "foo-bar-.com"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.hostname")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.hostname"), + ConstraintId: proto.String("string.hostname"), + }, + ), }, "hostname/invalid/leading_hyphen": { Message: &cases.StringHostname{Val: "-foo-bar.com"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.hostname")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.hostname"), + ConstraintId: proto.String("string.hostname"), + }, + ), }, "hostname/invalid/empty_part": { Message: &cases.StringHostname{Val: "foo..bar.com"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.hostname")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.hostname"), + ConstraintId: proto.String("string.hostname"), + }, + ), }, "hostname/invalid/IDNs": { Message: &cases.StringHostname{Val: "你好.com"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.hostname")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.hostname"), + ConstraintId: proto.String("string.hostname"), + }, + ), }, "hostname/invalid/only_dot": { Message: &cases.StringHostname{Val: "."}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.hostname")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.hostname"), + ConstraintId: proto.String("string.hostname"), + }, + ), }, "ip/valid/v4": { Message: &cases.StringIP{Val: "192.168.0.1"}, @@ -435,7 +641,12 @@ func stringSuite() suites.Suite { "ip/invalid": { Message: &cases.StringIP{Val: "foobar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ip")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ip"), + ConstraintId: proto.String("string.ip"), + }, + ), }, "ip/invalid/not_checked/empty": { Message: &cases.StringNotIP{Val: "foobar"}, @@ -448,7 +659,12 @@ func stringSuite() suites.Suite { "ip/invalid/empty": { Message: &cases.StringIP{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ip_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ip"), + ConstraintId: proto.String("string.ip_empty"), + }, + ), }, "ipv4/valid": { Message: &cases.StringIPv4{Val: "192.168.0.1"}, @@ -457,7 +673,12 @@ func stringSuite() suites.Suite { "ipv4/invalid/empty": { Message: &cases.StringIPv4{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv4_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv4"), + ConstraintId: proto.String("string.ipv4_empty"), + }, + ), }, "ipv4/invalid/not_checked/empty": { Message: &cases.StringNotIPv4{Val: ""}, @@ -470,17 +691,32 @@ func stringSuite() suites.Suite { "ipv4/invalid/malformed": { Message: &cases.StringIPv4{Val: "foobar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv4")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv4"), + ConstraintId: proto.String("string.ipv4"), + }, + ), }, "ipv4/invalid/erroneous": { Message: &cases.StringIPv4{Val: "256.0.0.0"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv4")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv4"), + ConstraintId: proto.String("string.ipv4"), + }, + ), }, "ipv4/invalid/v6": { Message: &cases.StringIPv4{Val: "3e::99"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv4")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv4"), + ConstraintId: proto.String("string.ipv4"), + }, + ), }, "ipv6/valid/expanded": { Message: &cases.StringIPv6{Val: "2001:0db8:85a3:0000:0000:8a2e:0370:7334"}, @@ -493,7 +729,12 @@ func stringSuite() suites.Suite { "ipv6/invalid/empty": { Message: &cases.StringIPv6{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv6_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv6"), + ConstraintId: proto.String("string.ipv6_empty"), + }, + ), }, "ipv6/invalid/not_checked/empty": { Message: &cases.StringNotIPv6{Val: ""}, @@ -506,17 +747,32 @@ func stringSuite() suites.Suite { "ipv6/invalid/malformed": { Message: &cases.StringIPv6{Val: "foobar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv6")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv6"), + ConstraintId: proto.String("string.ipv6"), + }, + ), }, "ipv6/invalid/erroneous": { Message: &cases.StringIPv6{Val: "ff::fff::0b"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv6")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv6"), + ConstraintId: proto.String("string.ipv6"), + }, + ), }, "ipv6/invalid/v4": { Message: &cases.StringIPv6{Val: "192.168.0.1"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv6")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv6"), + ConstraintId: proto.String("string.ipv6"), + }, + ), }, "ip_with_prefixlen/valid/v4": { Message: &cases.StringIPWithPrefixLen{Val: "192.168.0.1/24"}, @@ -529,7 +785,12 @@ func stringSuite() suites.Suite { "ip_with_prefixlen/invalid": { Message: &cases.StringIPWithPrefixLen{Val: "foobar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ip_with_prefixlen")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ip_with_prefixlen"), + ConstraintId: proto.String("string.ip_with_prefixlen"), + }, + ), }, "ip_with_prefixlen/invalid/not_checked/empty": { Message: &cases.StringNotIPWithPrefixLen{Val: ""}, @@ -542,7 +803,12 @@ func stringSuite() suites.Suite { "ip_with_prefixlen/invalid/empty": { Message: &cases.StringIPWithPrefixLen{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ip_with_prefixlen_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ip_with_prefixlen"), + ConstraintId: proto.String("string.ip_with_prefixlen_empty"), + }, + ), }, "ipv4_with_prefixlen/valid": { Message: &cases.StringIPv4WithPrefixLen{Val: "192.168.0.1/24"}, @@ -551,7 +817,12 @@ func stringSuite() suites.Suite { "ipv4_with_prefixlen/invalid/empty": { Message: &cases.StringIPv4WithPrefixLen{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv4_with_prefixlen_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv4_with_prefixlen"), + ConstraintId: proto.String("string.ipv4_with_prefixlen_empty"), + }, + ), }, "ipv4_with_prefixlen/invalid/not_checked/empty": { Message: &cases.StringNotIPv4WithPrefixLen{Val: ""}, @@ -564,12 +835,22 @@ func stringSuite() suites.Suite { "ipv4_with_prefixlen/invalid/malformed": { Message: &cases.StringIPv4WithPrefixLen{Val: "foobar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv4_with_prefixlen")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv4_with_prefixlen"), + ConstraintId: proto.String("string.ipv4_with_prefixlen"), + }, + ), }, "ipv4_with_prefixlen/invalid/v6": { Message: &cases.StringIPv4WithPrefixLen{Val: "2001:db8:1::1/64"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv4_with_prefixlen")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv4_with_prefixlen"), + ConstraintId: proto.String("string.ipv4_with_prefixlen"), + }, + ), }, "ipv6_with_prefixlen/valid/v6": { Message: &cases.StringIPv6WithPrefixLen{Val: "2001:db8:1::1/64"}, @@ -578,7 +859,12 @@ func stringSuite() suites.Suite { "ipv6_with_prefixlen/invalid/invalid": { Message: &cases.StringIPv6WithPrefixLen{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv6_with_prefixlen_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv6_with_prefixlen"), + ConstraintId: proto.String("string.ipv6_with_prefixlen_empty"), + }, + ), }, "ipv6_with_prefixlen/invalid/not_checked/empty": { Message: &cases.StringNotIPv6WithPrefixLen{Val: ""}, @@ -591,12 +877,22 @@ func stringSuite() suites.Suite { "ipv6_with_prefixlen/invalid/malformed": { Message: &cases.StringIPv6WithPrefixLen{Val: "foobar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv6_with_prefixlen")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv6_with_prefixlen"), + ConstraintId: proto.String("string.ipv6_with_prefixlen"), + }, + ), }, "ipv6_with_prefixlen/invalid/v4": { Message: &cases.StringIPv6WithPrefixLen{Val: "192.168.0.1/24"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv6_with_prefixlen")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv6_with_prefixlen"), + ConstraintId: proto.String("string.ipv6_with_prefixlen"), + }, + ), }, "ip_prefix/valid/v4": { Message: &cases.StringIPPrefix{Val: "192.168.0.0/24"}, @@ -609,7 +905,12 @@ func stringSuite() suites.Suite { "ip_prefix/invalid/empty": { Message: &cases.StringIPPrefix{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ip_prefix_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ip_prefix"), + ConstraintId: proto.String("string.ip_prefix_empty"), + }, + ), }, "ip_prefix/invalid/not_checked/empty": { Message: &cases.StringNotIPPrefix{Val: ""}, @@ -622,7 +923,12 @@ func stringSuite() suites.Suite { "ip_prefix/invalid/malformed": { Message: &cases.StringIPPrefix{Val: "foobar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ip_prefix")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ip_prefix"), + ConstraintId: proto.String("string.ip_prefix"), + }, + ), }, "ipv4_prefix/valid": { Message: &cases.StringIPv4Prefix{Val: "192.168.0.0/24"}, @@ -631,7 +937,12 @@ func stringSuite() suites.Suite { "ipv4_prefix/invalid/empty": { Message: &cases.StringIPv4Prefix{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv4_prefix_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv4_prefix"), + ConstraintId: proto.String("string.ipv4_prefix_empty"), + }, + ), }, "ipv4_prefix/invalid/not_checked/empty": { Message: &cases.StringNotIPv4Prefix{Val: ""}, @@ -644,17 +955,32 @@ func stringSuite() suites.Suite { "ipv4_prefix/invalid/not_network_address": { Message: &cases.StringIPv4Prefix{Val: "192.168.0.1/24"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv4_prefix")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv4_prefix"), + ConstraintId: proto.String("string.ipv4_prefix"), + }, + ), }, "ipv4_prefix/invalid/malformed": { Message: &cases.StringIPv4Prefix{Val: "foobar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv4_prefix")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv4_prefix"), + ConstraintId: proto.String("string.ipv4_prefix"), + }, + ), }, "ipv4_prefix/invalid/v6": { Message: &cases.StringIPv4Prefix{Val: "2001:db8:1::/48"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv4_prefix")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv4_prefix"), + ConstraintId: proto.String("string.ipv4_prefix"), + }, + ), }, "ipv6_prefix/valid/v6": { Message: &cases.StringIPv6Prefix{Val: "2001:db8:1::/48"}, @@ -663,7 +989,12 @@ func stringSuite() suites.Suite { "ipv6_prefix/invalid/empty": { Message: &cases.StringIPv6Prefix{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv6_prefix_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv6_prefix"), + ConstraintId: proto.String("string.ipv6_prefix_empty"), + }, + ), }, "ipv6_prefix/invalid/not_checked/empty": { Message: &cases.StringNotIPv6Prefix{Val: ""}, @@ -676,17 +1007,32 @@ func stringSuite() suites.Suite { "ipv6_prefix/invalid/not_network_address": { Message: &cases.StringIPv6Prefix{Val: "2001:db8:1::1/48"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv6_prefix")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv6_prefix"), + ConstraintId: proto.String("string.ipv6_prefix"), + }, + ), }, "ipv6_prefix/invalid/malformed": { Message: &cases.StringIPv6Prefix{Val: "foobar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv6_prefix")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv6_prefix"), + ConstraintId: proto.String("string.ipv6_prefix"), + }, + ), }, "ipv6_prefix/invalid/v4": { Message: &cases.StringIPv6Prefix{Val: "192.168.0.0/24"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.ipv6_prefix")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.ipv6_prefix"), + ConstraintId: proto.String("string.ipv6_prefix"), + }, + ), }, "uri/valid": { Message: &cases.StringURI{Val: "https://example.com/foo/bar?baz=quux"}, @@ -695,7 +1041,12 @@ func stringSuite() suites.Suite { "uri/invalid/empty": { Message: &cases.StringURI{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.uri_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.uri"), + ConstraintId: proto.String("string.uri_empty"), + }, + ), }, "uri/invalid/not_checked/empty": { Message: &cases.StringNotURI{Val: ""}, @@ -708,12 +1059,22 @@ func stringSuite() suites.Suite { "uri/invalid/malformed": { Message: &cases.StringURI{Val: "!@#$%^&*"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.uri")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.uri"), + ConstraintId: proto.String("string.uri"), + }, + ), }, "uri/invalid/relative": { Message: &cases.StringURI{Val: "/foo/bar?baz=quux"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.uri")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.uri"), + ConstraintId: proto.String("string.uri"), + }, + ), }, "uri_ref/valid/absolute": { Message: &cases.StringURIRef{Val: "https://example.com/foo/bar?baz=quux"}, @@ -726,7 +1087,12 @@ func stringSuite() suites.Suite { "uri_ref/invalid": { Message: &cases.StringURIRef{Val: "!@#$%^&*"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.uri_ref")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.uri_ref"), + ConstraintId: proto.String("string.uri_ref"), + }, + ), }, "uri_ref/invalid/not_checked/empty": { Message: &cases.StringNotURIRef{Val: ""}, @@ -751,7 +1117,12 @@ func stringSuite() suites.Suite { "address/invalid/empty": { Message: &cases.StringAddress{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.address_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.address"), + ConstraintId: proto.String("string.address_empty"), + }, + ), }, "address/invalid/not_checked/empty": { Message: &cases.StringNotAddress{Val: ""}, @@ -764,12 +1135,22 @@ func stringSuite() suites.Suite { "address/invalid/hostname": { Message: &cases.StringAddress{Val: "-foo.bar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.address")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.address"), + ConstraintId: proto.String("string.address"), + }, + ), }, "address/invalid/ipv6": { Message: &cases.StringAddress{Val: "ff::fff::0b"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.address")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.address"), + ConstraintId: proto.String("string.address"), + }, + ), }, "uuid/valid/nil": { Message: &cases.StringUUID{Val: "00000000-0000-0000-0000-000000000000"}, @@ -818,7 +1199,12 @@ func stringSuite() suites.Suite { "uuid/invalid/empty": { Message: &cases.StringUUID{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.uuid_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.uuid"), + ConstraintId: proto.String("string.uuid_empty"), + }, + ), }, "uuid/invalid/not_checked/empty": { Message: &cases.StringNotUUID{Val: ""}, @@ -831,22 +1217,42 @@ func stringSuite() suites.Suite { "uuid/invalid/malformed": { Message: &cases.StringUUID{Val: "foobar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.uuid")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.uuid"), + ConstraintId: proto.String("string.uuid"), + }, + ), }, "uuid/invalid/erroneous": { Message: &cases.StringUUID{Val: "ffffffff-ffff-ffff-ffff-fffffffffffff"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.uuid")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.uuid"), + ConstraintId: proto.String("string.uuid"), + }, + ), }, "uuid/invalid/dashless/uppercase": { Message: &cases.StringUUID{Val: "8B20830500E84460A4405E0DCD83BB0A"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.uuid")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.uuid"), + ConstraintId: proto.String("string.uuid"), + }, + ), }, "uuid/invalid/dashless/lowercase": { Message: &cases.StringUUID{Val: "8b20830500e84460a4405e0dcd83bb0a"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.uuid")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.uuid"), + ConstraintId: proto.String("string.uuid"), + }, + ), }, "tuuid/valid/nil": { Message: &cases.StringTUUID{Val: "00000000000000000000000000000000"}, @@ -895,7 +1301,12 @@ func stringSuite() suites.Suite { "tuuid/invalid/empty": { Message: &cases.StringTUUID{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.tuuid_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.tuuid"), + ConstraintId: proto.String("string.tuuid_empty"), + }, + ), }, "tuuid/invalid/not_checked/empty": { Message: &cases.StringNotTUUID{Val: ""}, @@ -908,22 +1319,42 @@ func stringSuite() suites.Suite { "tuuid/invalid/malformed": { Message: &cases.StringTUUID{Val: "foobar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.tuuid")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.tuuid"), + ConstraintId: proto.String("string.tuuid"), + }, + ), }, "tuuid/invalid/erroneous": { Message: &cases.StringTUUID{Val: "fffffffffffffffffffffffffffffffff"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.tuuid")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.tuuid"), + ConstraintId: proto.String("string.tuuid"), + }, + ), }, "tuuid/invalid/dashful/uppercase": { Message: &cases.StringTUUID{Val: "8B208305-00E8-4460-A440-5E0DCD83BB0A"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.tuuid")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.tuuid"), + ConstraintId: proto.String("string.tuuid"), + }, + ), }, "tuuid/invalid/dashful/lowercase": { Message: &cases.StringTUUID{Val: "8b208305-00e8-4460-a440-5e0dcd83bb0a"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.tuuid")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.tuuid"), + ConstraintId: proto.String("string.tuuid"), + }, + ), }, "well_known_regex/header_name/strict/valid/header": { Message: &cases.StringHttpHeaderName{Val: "clustername"}, @@ -948,47 +1379,92 @@ func stringSuite() suites.Suite { "well_known_regex/header_name/strict/invalid/empty": { Message: &cases.StringHttpHeaderName{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_name_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_name_empty"), + }, + ), }, "well_known_regex/header_name/strict/invalid/solo_colon": { Message: &cases.StringHttpHeaderName{Val: ":"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_name")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_name"), + }, + ), }, "well_known_regex/header_name/strict/invalid/trailing_colon": { Message: &cases.StringHttpHeaderName{Val: ":foo:"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_name")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_name"), + }, + ), }, "well_known_regex/header_name/strict/invalid/space": { Message: &cases.StringHttpHeaderName{Val: "foo bar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_name")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_name"), + }, + ), }, "well_known_regex/header_name/strict/invalid/cr": { Message: &cases.StringHttpHeaderName{Val: "foo\rbar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_name")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_name"), + }, + ), }, "well_known_regex/header_name/strict/invalid/lf": { Message: &cases.StringHttpHeaderName{Val: "foo\nbar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_name")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_name"), + }, + ), }, "well_known_regex/header_name/strict/invalid/tab": { Message: &cases.StringHttpHeaderName{Val: "foo\tbar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_name")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_name"), + }, + ), }, "well_known_regex/header_name/strict/invalid/nul": { Message: &cases.StringHttpHeaderName{Val: "foo\000bar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_name")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_name"), + }, + ), }, "well_known_regex/header_name/strict/invalid/slash": { Message: &cases.StringHttpHeaderName{Val: "foo/bar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_name")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_name"), + }, + ), }, "well_known_regex/header_name/loose/valid/slash": { Message: &cases.StringHttpHeaderNameLoose{Val: "FOO/BAR"}, @@ -1005,17 +1481,32 @@ func stringSuite() suites.Suite { "well_known_regex/header_name/loose/invalid/empty": { Message: &cases.StringHttpHeaderNameLoose{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_name_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_name_empty"), + }, + ), }, "well_known_regex/header_name/loose/invalid/cr": { Message: &cases.StringHttpHeaderNameLoose{Val: "foo\rbar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_name")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_name"), + }, + ), }, "well_known_regex/header_name/loose/invalid/lf": { Message: &cases.StringHttpHeaderNameLoose{Val: "foo\nbar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_name")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_name"), + }, + ), }, "well_known_regex/header_value/strict/valid/empty": { Message: &cases.StringHttpHeaderValue{Val: ""}, @@ -1044,22 +1535,42 @@ func stringSuite() suites.Suite { "well_known_regex/header_value/strict/invalid/nul": { Message: &cases.StringHttpHeaderValue{Val: "foo\000bar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_value")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_value"), + }, + ), }, "well_known_regex/header_value/strict/invalid/del": { Message: &cases.StringHttpHeaderValue{Val: "foo\007bar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_value")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_value"), + }, + ), }, "well_known_regex/header_value/strict/invalid/cr": { Message: &cases.StringHttpHeaderValue{Val: "foo\rbar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_value")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_value"), + }, + ), }, "well_known_regex/header_value/strict/invalid/lf": { Message: &cases.StringHttpHeaderValue{Val: "foo\nbar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_value")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_value"), + }, + ), }, "well_known_regex/header_name/loose/valid/del": { Message: &cases.StringHttpHeaderNameLoose{Val: "FOO\007BAR"}, @@ -1068,17 +1579,32 @@ func stringSuite() suites.Suite { "well_known_regex/header_value/loose/invalid/nul": { Message: &cases.StringHttpHeaderValueLoose{Val: "\000"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_value")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_value"), + }, + ), }, "well_known_regex/header_value/loose/invalid/cr": { Message: &cases.StringHttpHeaderValueLoose{Val: "foo\rbar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_value")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_value"), + }, + ), }, "well_known_regex/header_value/loose/invalid/lf": { Message: &cases.StringHttpHeaderValueLoose{Val: "foo\nbar"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.well_known_regex.header_value")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.well_known_regex"), + ConstraintId: proto.String("string.well_known_regex.header_value"), + }, + ), }, "host_and_port/valid/hostname": { Message: &cases.StringHostAndPort{Val: "localhost:1234"}, @@ -1095,42 +1621,82 @@ func stringSuite() suites.Suite { "host_and_port/invalid/empty": { Message: &cases.StringHostAndPort{Val: ""}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.host_and_port_empty")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.host_and_port"), + ConstraintId: proto.String("string.host_and_port_empty"), + }, + ), }, "host_and_port/invalid/missing_port": { Message: &cases.StringHostAndPort{Val: "localhost"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.host_and_port")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.host_and_port"), + ConstraintId: proto.String("string.host_and_port"), + }, + ), }, "host_and_port/invalid/whitespace": { Message: &cases.StringHostAndPort{Val: " localhost:8080 "}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.host_and_port")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.host_and_port"), + ConstraintId: proto.String("string.host_and_port"), + }, + ), }, "host_and_port/invalid/malformed_hostname": { Message: &cases.StringHostAndPort{Val: "abc#123:456"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.host_and_port")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.host_and_port"), + ConstraintId: proto.String("string.host_and_port"), + }, + ), }, "host_and_port/invalid/malformed_ipv4": { Message: &cases.StringHostAndPort{Val: "123.456.789.100:8080"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.host_and_port")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.host_and_port"), + ConstraintId: proto.String("string.host_and_port"), + }, + ), }, "host_and_port/invalid/malformed_ipv6": { Message: &cases.StringHostAndPort{Val: "[1::jk::3]:8080"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.host_and_port")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.host_and_port"), + ConstraintId: proto.String("string.host_and_port"), + }, + ), }, "host_and_port/invalid/unbracketed_ipv6": { Message: &cases.StringHostAndPort{Val: "::1:8080"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.host_and_port")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.host_and_port"), + ConstraintId: proto.String("string.host_and_port"), + }, + ), }, "host_and_port/invalid/port_out_of_range": { Message: &cases.StringHostAndPort{Val: "localhost:99999"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.host_and_port")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.host_and_port"), + ConstraintId: proto.String("string.host_and_port"), + }, + ), }, "host_and_port/optional_port/valid/hostname": { Message: &cases.StringHostAndOptionalPort{Val: "localhost"}, @@ -1159,17 +1725,32 @@ func stringSuite() suites.Suite { "host_and_port/optional_port/invalid/malformed_hostname": { Message: &cases.StringHostAndOptionalPort{Val: "abc#123"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.host_and_port.optional_port")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("string.host_and_port.optional_port"), + }, + ), }, "host_and_port/optional_port/invalid/malformed_ipv4": { Message: &cases.StringHostAndOptionalPort{Val: "123.456.789.100"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.host_and_port.optional_port")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("string.host_and_port.optional_port"), + }, + ), }, "host_and_port/optional_port/invalid/malformed_ipv6": { Message: &cases.StringHostAndOptionalPort{Val: "[1::jk::3]"}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("string.host_and_port.optional_port")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("cel[0]"), + ConstraintId: proto.String("string.host_and_port.optional_port"), + }, + ), }, "example/valid": { Message: &cases.StringExample{Val: "foobar"}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_timestamp.go b/tools/protovalidate-conformance/internal/cases/cases_timestamp.go index 510560ee..40d83135 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_timestamp.go +++ b/tools/protovalidate-conformance/internal/cases/cases_timestamp.go @@ -36,8 +36,12 @@ func timestampSuite() suites.Suite { Expected: results.Success(true), }, "required/invalid": { - Message: &cases.TimestampRequired{Val: nil}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required")}), + Message: &cases.TimestampRequired{Val: nil}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), + ConstraintId: proto.String("required"), + }), }, "const/valid": { Message: &cases.TimestampConst{Val: ×tamppb.Timestamp{Seconds: 3, Nanos: 0}}, @@ -48,8 +52,12 @@ func timestampSuite() suites.Suite { Expected: results.Success(true), }, "const/invalid": { - Message: &cases.TimestampConst{Val: ×tamppb.Timestamp{Nanos: 3}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.const")}), + Message: &cases.TimestampConst{Val: ×tamppb.Timestamp{Nanos: 3}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.const"), + ConstraintId: proto.String("timestamp.const"), + }), }, "lt/valid": { Message: &cases.TimestampLT{Val: ×tamppb.Timestamp{Seconds: -1}}, @@ -60,12 +68,20 @@ func timestampSuite() suites.Suite { Expected: results.Success(true), }, "lt/invalid/equal": { - Message: &cases.TimestampLT{Val: ×tamppb.Timestamp{}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.lt")}), + Message: &cases.TimestampLT{Val: ×tamppb.Timestamp{}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.lt"), + ConstraintId: proto.String("timestamp.lt"), + }), }, "lt/invalid": { - Message: &cases.TimestampLT{Val: ×tamppb.Timestamp{Seconds: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.lt")}), + Message: &cases.TimestampLT{Val: ×tamppb.Timestamp{Seconds: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.lt"), + ConstraintId: proto.String("timestamp.lt"), + }), }, "lte/valid": { Message: &cases.TimestampLTE{Val: ×tamppb.Timestamp{}}, @@ -80,8 +96,12 @@ func timestampSuite() suites.Suite { Expected: results.Success(true), }, "lte/invalid": { - Message: &cases.TimestampLTE{Val: ×tamppb.Timestamp{Seconds: 1, Nanos: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.lte")}), + Message: &cases.TimestampLTE{Val: ×tamppb.Timestamp{Seconds: 1, Nanos: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.lte"), + ConstraintId: proto.String("timestamp.lte"), + }), }, "gt/valid": { Message: &cases.TimestampGT{Val: ×tamppb.Timestamp{Seconds: 1}}, @@ -92,12 +112,20 @@ func timestampSuite() suites.Suite { Expected: results.Success(true), }, "gt/invalid/equal": { - Message: &cases.TimestampGT{Val: ×tamppb.Timestamp{Nanos: 1000}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gt")}), + Message: &cases.TimestampGT{Val: ×tamppb.Timestamp{Nanos: 1000}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gt"), + ConstraintId: proto.String("timestamp.gt"), + }), }, "gt/invalid": { - Message: &cases.TimestampGT{Val: ×tamppb.Timestamp{}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gt")}), + Message: &cases.TimestampGT{Val: ×tamppb.Timestamp{}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gt"), + ConstraintId: proto.String("timestamp.gt"), + }), }, "gte/valid": { Message: &cases.TimestampGTE{Val: ×tamppb.Timestamp{Seconds: 3}}, @@ -112,8 +140,12 @@ func timestampSuite() suites.Suite { Expected: results.Success(true), }, "gte/invalid": { - Message: &cases.TimestampGTE{Val: ×tamppb.Timestamp{Seconds: -1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gte")}), + Message: &cases.TimestampGTE{Val: ×tamppb.Timestamp{Seconds: -1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gte"), + ConstraintId: proto.String("timestamp.gte"), + }), }, "gt_lt/valid": { Message: &cases.TimestampGTLT{Val: ×tamppb.Timestamp{Nanos: 1000}}, @@ -124,20 +156,36 @@ func timestampSuite() suites.Suite { Expected: results.Success(true), }, "gt_lt/invalid/above": { - Message: &cases.TimestampGTLT{Val: ×tamppb.Timestamp{Seconds: 1000}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gt_lt")}), + Message: &cases.TimestampGTLT{Val: ×tamppb.Timestamp{Seconds: 1000}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gt"), + ConstraintId: proto.String("timestamp.gt_lt"), + }), }, "gt_lt/invalid/below": { - Message: &cases.TimestampGTLT{Val: ×tamppb.Timestamp{Seconds: -1000}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gt_lt")}), + Message: &cases.TimestampGTLT{Val: ×tamppb.Timestamp{Seconds: -1000}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gt"), + ConstraintId: proto.String("timestamp.gt_lt"), + }), }, "gt_lt/invalid/max": { - Message: &cases.TimestampGTLT{Val: ×tamppb.Timestamp{Seconds: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gt_lt")}), + Message: &cases.TimestampGTLT{Val: ×tamppb.Timestamp{Seconds: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gt"), + ConstraintId: proto.String("timestamp.gt_lt"), + }), }, "gt_lt/invalid/min": { - Message: &cases.TimestampGTLT{Val: ×tamppb.Timestamp{}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gt_lt")}), + Message: &cases.TimestampGTLT{Val: ×tamppb.Timestamp{}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gt"), + ConstraintId: proto.String("timestamp.gt_lt"), + }), }, "exclusive/gt_lt/valid/empty": { Message: &cases.TimestampExLTGT{}, @@ -152,16 +200,28 @@ func timestampSuite() suites.Suite { Expected: results.Success(true), }, "exclusive/gt_lt/invalid": { - Message: &cases.TimestampExLTGT{Val: ×tamppb.Timestamp{Nanos: 1000}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gt_lt_exclusive")}), + Message: &cases.TimestampExLTGT{Val: ×tamppb.Timestamp{Nanos: 1000}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gt"), + ConstraintId: proto.String("timestamp.gt_lt_exclusive"), + }), }, "exclusive/gt_lt/invalid/max": { - Message: &cases.TimestampExLTGT{Val: ×tamppb.Timestamp{Seconds: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gt_lt_exclusive")}), + Message: &cases.TimestampExLTGT{Val: ×tamppb.Timestamp{Seconds: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gt"), + ConstraintId: proto.String("timestamp.gt_lt_exclusive"), + }), }, "exclusive/gt_lt/invalid/min": { - Message: &cases.TimestampExLTGT{Val: ×tamppb.Timestamp{}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gt_lt_exclusive")}), + Message: &cases.TimestampExLTGT{Val: ×tamppb.Timestamp{}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gt"), + ConstraintId: proto.String("timestamp.gt_lt_exclusive"), + }), }, "gte_lte/valid": { Message: &cases.TimestampGTELTE{Val: ×tamppb.Timestamp{Seconds: 60, Nanos: 1}}, @@ -180,12 +240,20 @@ func timestampSuite() suites.Suite { Expected: results.Success(true), }, "gte_lte/invalid/above": { - Message: &cases.TimestampGTELTE{Val: ×tamppb.Timestamp{Seconds: 3600, Nanos: 1}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gte_lte")}), + Message: &cases.TimestampGTELTE{Val: ×tamppb.Timestamp{Seconds: 3600, Nanos: 1}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gte"), + ConstraintId: proto.String("timestamp.gte_lte"), + }), }, "gte_lte/invalid/below": { - Message: &cases.TimestampGTELTE{Val: ×tamppb.Timestamp{Seconds: 59}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gte_lte")}), + Message: &cases.TimestampGTELTE{Val: ×tamppb.Timestamp{Seconds: 59}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gte"), + ConstraintId: proto.String("timestamp.gte_lte"), + }), }, "exclusive/gte_lte/valid/empty": { Message: &cases.TimestampExGTELTE{}, @@ -208,8 +276,12 @@ func timestampSuite() suites.Suite { Expected: results.Success(true), }, "exclusive/gte_lte/invalid": { - Message: &cases.TimestampExGTELTE{Val: ×tamppb.Timestamp{Seconds: 61}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gte_lte_exclusive")}), + Message: &cases.TimestampExGTELTE{Val: ×tamppb.Timestamp{Seconds: 61}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gte"), + ConstraintId: proto.String("timestamp.gte_lte_exclusive"), + }), }, "lt_now/valid": { Message: &cases.TimestampLTNow{Val: ×tamppb.Timestamp{}}, @@ -220,8 +292,12 @@ func timestampSuite() suites.Suite { Expected: results.Success(true), }, "lt_now/invalid": { - Message: &cases.TimestampLTNow{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 7200}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.lt_now")}), + Message: &cases.TimestampLTNow{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 7200}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.lt_now"), + ConstraintId: proto.String("timestamp.lt_now"), + }), }, "lt_now/invalid/not_checked": { Message: &cases.TimestampNotLTNow{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 7200}}, @@ -236,8 +312,12 @@ func timestampSuite() suites.Suite { Expected: results.Success(true), }, "gt_now/invalid": { - Message: &cases.TimestampGTNow{Val: ×tamppb.Timestamp{}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gt_now")}), + Message: &cases.TimestampGTNow{Val: ×tamppb.Timestamp{}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gt_now"), + ConstraintId: proto.String("timestamp.gt_now"), + }), }, "gt_now/invalid/not_checked": { Message: &cases.TimestampNotGTNow{Val: ×tamppb.Timestamp{}}, @@ -252,12 +332,20 @@ func timestampSuite() suites.Suite { Expected: results.Success(true), }, "within/invalid/below": { - Message: &cases.TimestampWithin{Val: ×tamppb.Timestamp{}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.within")}), + Message: &cases.TimestampWithin{Val: ×tamppb.Timestamp{}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.within"), + ConstraintId: proto.String("timestamp.within"), + }), }, "within/invalid/above": { - Message: &cases.TimestampWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 7200}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.within")}), + Message: &cases.TimestampWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 7200}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.within"), + ConstraintId: proto.String("timestamp.within"), + }), }, "lt_now/within/valid": { Message: &cases.TimestampLTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() - 1800}}, @@ -270,11 +358,19 @@ func timestampSuite() suites.Suite { "lt_now/within/invalid/lt": { Message: &cases.TimestampLTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 1800}}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.lt_now")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.lt_now"), + ConstraintId: proto.String("timestamp.lt_now"), + }), }, "lt_now/within/invalid/within": { - Message: &cases.TimestampLTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() / 7200}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.within")}), + Message: &cases.TimestampLTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() / 7200}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.within"), + ConstraintId: proto.String("timestamp.within"), + }), }, "gt_now/within/valid": { Message: &cases.TimestampGTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 1800}}, @@ -287,13 +383,23 @@ func timestampSuite() suites.Suite { "gt_now/within/invalid/gt": { Message: &cases.TimestampGTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() / 1800}}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.gt_now")}, - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.within")}, + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.gt_now"), + ConstraintId: proto.String("timestamp.gt_now")}, + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.within"), + ConstraintId: proto.String("timestamp.within")}, ), }, "gt_now/within/invalid/within": { - Message: &cases.TimestampGTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 7200}}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("timestamp.within")}), + Message: &cases.TimestampGTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 7200}}, + Expected: results.Violations(&validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("timestamp.within"), + ConstraintId: proto.String("timestamp.within"), + }), }, "example/valid": { Message: &cases.TimestampExample{Val: ×tamppb.Timestamp{Seconds: 3, Nanos: 0}}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_uint32.go b/tools/protovalidate-conformance/internal/cases/cases_uint32.go index ff45a3bc..3ec2b8b6 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_uint32.go +++ b/tools/protovalidate-conformance/internal/cases/cases_uint32.go @@ -35,7 +35,12 @@ func uint32Suite() suites.Suite { "const/invalid": { Message: &cases.UInt32Const{Val: 2}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.const"), + ConstraintId: proto.String("uint32.const"), + }, + ), }, "in/valid": { Message: &cases.UInt32In{Val: 3}, @@ -44,7 +49,12 @@ func uint32Suite() suites.Suite { "in/invalid": { Message: &cases.UInt32In{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.in"), + ConstraintId: proto.String("uint32.in"), + }, + ), }, "not_in/valid": { Message: &cases.UInt32NotIn{Val: 1}, @@ -53,7 +63,12 @@ func uint32Suite() suites.Suite { "not_in/invalid": { Message: &cases.UInt32NotIn{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.not_in"), + ConstraintId: proto.String("uint32.not_in"), + }, + ), }, "lt/valid/less": { Message: &cases.UInt32LT{Val: 4}, @@ -62,12 +77,22 @@ func uint32Suite() suites.Suite { "lt/invalid/equal": { Message: &cases.UInt32LT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.lt"), + ConstraintId: proto.String("uint32.lt"), + }, + ), }, "lt/invalid/greater": { Message: &cases.UInt32LT{Val: 6}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.lt"), + ConstraintId: proto.String("uint32.lt"), + }, + ), }, "lte/valid/less": { Message: &cases.UInt32LTE{Val: 63}, @@ -80,7 +105,12 @@ func uint32Suite() suites.Suite { "lte/invalid/greater": { Message: &cases.UInt32LTE{Val: 65}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.lte"), + ConstraintId: proto.String("uint32.lte"), + }, + ), }, "gt/valid/greater": { Message: &cases.UInt32GT{Val: 17}, @@ -89,12 +119,22 @@ func uint32Suite() suites.Suite { "gt/invalid/equal": { Message: &cases.UInt32GT{Val: 16}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gt"), + ConstraintId: proto.String("uint32.gt"), + }, + ), }, "gt/invalid/less": { Message: &cases.UInt32GT{Val: 15}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gt"), + ConstraintId: proto.String("uint32.gt"), + }, + ), }, "gte/valid/greater": { Message: &cases.UInt32GTE{Val: 9}, @@ -107,7 +147,12 @@ func uint32Suite() suites.Suite { "gte/invalid/less": { Message: &cases.UInt32GTE{Val: 7}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gte"), + ConstraintId: proto.String("uint32.gte"), + }, + ), }, "gt_lt/inclusive/valid/within": { Message: &cases.UInt32GTLT{Val: 6}, @@ -116,22 +161,42 @@ func uint32Suite() suites.Suite { "gt_lt/inclusive/invalid/above": { Message: &cases.UInt32GTLT{Val: 11}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gt"), + ConstraintId: proto.String("uint32.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/below": { Message: &cases.UInt32GTLT{Val: 4}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gt"), + ConstraintId: proto.String("uint32.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/max": { Message: &cases.UInt32GTLT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gt"), + ConstraintId: proto.String("uint32.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/min": { Message: &cases.UInt32GTLT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gt"), + ConstraintId: proto.String("uint32.gt_lt"), + }, + ), }, "gt_lt/exclusive/valid/above": { Message: &cases.UInt32ExLTGT{Val: 11}, @@ -144,17 +209,32 @@ func uint32Suite() suites.Suite { "gt_lt/exclusive/invalid/within": { Message: &cases.UInt32ExLTGT{Val: 6}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gt"), + ConstraintId: proto.String("uint32.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/max": { Message: &cases.UInt32ExLTGT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gt"), + ConstraintId: proto.String("uint32.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/min": { Message: &cases.UInt32ExLTGT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gt"), + ConstraintId: proto.String("uint32.gt_lt_exclusive"), + }, + ), }, "gte_lte/inclusive/valid/within": { Message: &cases.UInt32GTELTE{Val: 200}, @@ -171,12 +251,22 @@ func uint32Suite() suites.Suite { "gte_lte/inclusive/invalid/above": { Message: &cases.UInt32GTELTE{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gte"), + ConstraintId: proto.String("uint32.gte_lte"), + }, + ), }, "gte_lte/inclusive/invalid/below": { Message: &cases.UInt32GTELTE{Val: 100}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gte"), + ConstraintId: proto.String("uint32.gte_lte"), + }, + ), }, "gte_lte/exclusive/valid/above": { Message: &cases.UInt32ExGTELTE{Val: 300}, @@ -197,7 +287,12 @@ func uint32Suite() suites.Suite { "gte_lte/exclusive/invalid/within": { Message: &cases.UInt32ExGTELTE{Val: 200}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gte_lte_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gte"), + ConstraintId: proto.String("uint32.gte_lte_exclusive"), + }, + ), }, "ignore_empty/valid/empty": { Message: &cases.UInt32Ignore{Val: 0}, @@ -210,7 +305,12 @@ func uint32Suite() suites.Suite { "ignore_empty/invalid/above": { Message: &cases.UInt32Ignore{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint32.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gte"), + ConstraintId: proto.String("uint32.gte_lte"), + }, + ), }, "compilation/wrong_type": { Message: &cases.UInt32IncorrectType{Val: 123}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_uint64.go b/tools/protovalidate-conformance/internal/cases/cases_uint64.go index 8aa13231..ddaada06 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_uint64.go +++ b/tools/protovalidate-conformance/internal/cases/cases_uint64.go @@ -35,7 +35,12 @@ func uint64Suite() suites.Suite { "const/invalid": { Message: &cases.UInt64Const{Val: 2}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.const")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.const"), + ConstraintId: proto.String("uint64.const"), + }, + ), }, "in/valid": { Message: &cases.UInt64In{Val: 3}, @@ -44,7 +49,12 @@ func uint64Suite() suites.Suite { "in/invalid": { Message: &cases.UInt64In{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.in"), + ConstraintId: proto.String("uint64.in"), + }, + ), }, "not_in/valid": { Message: &cases.UInt64NotIn{Val: 1}, @@ -53,7 +63,12 @@ func uint64Suite() suites.Suite { "not_in/invalid": { Message: &cases.UInt64NotIn{Val: 0}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.not_in")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.not_in"), + ConstraintId: proto.String("uint64.not_in"), + }, + ), }, "lt/valid/less": { Message: &cases.UInt64LT{Val: 4}, @@ -62,12 +77,22 @@ func uint64Suite() suites.Suite { "lt/invalid/equal": { Message: &cases.UInt64LT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.lt"), + ConstraintId: proto.String("uint64.lt"), + }, + ), }, "lt/invalid/greater": { Message: &cases.UInt64LT{Val: 6}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.lt"), + ConstraintId: proto.String("uint64.lt"), + }, + ), }, "lte/valid/less": { Message: &cases.UInt64LTE{Val: 63}, @@ -80,7 +105,12 @@ func uint64Suite() suites.Suite { "lte/invalid/greater": { Message: &cases.UInt64LTE{Val: 65}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.lte"), + ConstraintId: proto.String("uint64.lte"), + }, + ), }, "gt/valid/greater": { Message: &cases.UInt64GT{Val: 17}, @@ -89,12 +119,22 @@ func uint64Suite() suites.Suite { "gt/invalid/equal": { Message: &cases.UInt64GT{Val: 16}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gt"), + ConstraintId: proto.String("uint64.gt"), + }, + ), }, "gt/invalid/less": { Message: &cases.UInt64GT{Val: 15}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gt"), + ConstraintId: proto.String("uint64.gt"), + }, + ), }, "gte/valid/greater": { Message: &cases.UInt64GTE{Val: 9}, @@ -107,7 +147,12 @@ func uint64Suite() suites.Suite { "gte/invalid/less": { Message: &cases.UInt64GTE{Val: 7}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gte"), + ConstraintId: proto.String("uint64.gte"), + }, + ), }, "gt_lt/inclusive/valid/within": { Message: &cases.UInt64GTLT{Val: 6}, @@ -116,22 +161,42 @@ func uint64Suite() suites.Suite { "gt_lt/inclusive/invalid/above": { Message: &cases.UInt64GTLT{Val: 11}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gt"), + ConstraintId: proto.String("uint64.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/below": { Message: &cases.UInt64GTLT{Val: 4}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gt"), + ConstraintId: proto.String("uint64.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/max": { Message: &cases.UInt64GTLT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gt"), + ConstraintId: proto.String("uint64.gt_lt"), + }, + ), }, "gt_lt/inclusive/invalid/min": { Message: &cases.UInt64GTLT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gt_lt")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gt"), + ConstraintId: proto.String("uint64.gt_lt"), + }, + ), }, "gt_lt/exclusive/valid/above": { Message: &cases.UInt64ExLTGT{Val: 11}, @@ -144,17 +209,32 @@ func uint64Suite() suites.Suite { "gt_lt/exclusive/invalid/within": { Message: &cases.UInt64ExLTGT{Val: 6}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gt"), + ConstraintId: proto.String("uint64.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/max": { Message: &cases.UInt64ExLTGT{Val: 10}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gt"), + ConstraintId: proto.String("uint64.gt_lt_exclusive"), + }, + ), }, "gt_lt/exclusive/invalid/min": { Message: &cases.UInt64ExLTGT{Val: 5}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gt_lt_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gt"), + ConstraintId: proto.String("uint64.gt_lt_exclusive"), + }, + ), }, "gte_lte/inclusive/valid/within": { Message: &cases.UInt64GTELTE{Val: 200}, @@ -171,12 +251,22 @@ func uint64Suite() suites.Suite { "gte_lte/inclusive/invalid/above": { Message: &cases.UInt64GTELTE{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gte"), + ConstraintId: proto.String("uint64.gte_lte"), + }, + ), }, "gte_lte/inclusive/invalid/below": { Message: &cases.UInt64GTELTE{Val: 100}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gte"), + ConstraintId: proto.String("uint64.gte_lte"), + }, + ), }, "gte_lte/exclusive/valid/above": { Message: &cases.UInt64ExGTELTE{Val: 300}, @@ -197,7 +287,12 @@ func uint64Suite() suites.Suite { "gte_lte/exclusive/invalid/within": { Message: &cases.UInt64ExGTELTE{Val: 200}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gte_lte_exclusive")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gte"), + ConstraintId: proto.String("uint64.gte_lte_exclusive"), + }, + ), }, "ignore_empty/valid/empty": { Message: &cases.UInt64Ignore{Val: 0}, @@ -210,7 +305,12 @@ func uint64Suite() suites.Suite { "ignore_empty/invalid/above": { Message: &cases.UInt64Ignore{Val: 300}, Expected: results.Violations( - &validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("uint64.gte_lte")}), + &validate.Violation{ + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gte"), + ConstraintId: proto.String("uint64.gte_lte"), + }, + ), }, "compilation/wrong_type": { Message: &cases.UInt64IncorrectType{Val: 123}, diff --git a/tools/protovalidate-conformance/internal/cases/cases_wrapper.go b/tools/protovalidate-conformance/internal/cases/cases_wrapper.go index b929f2d7..a1accef2 100644 --- a/tools/protovalidate-conformance/internal/cases/cases_wrapper.go +++ b/tools/protovalidate-conformance/internal/cases/cases_wrapper.go @@ -44,7 +44,8 @@ func wrapperSuite() suites.Suite { "float/invalid": { Message: &cases.WrapperFloat{Val: &wrapperspb.FloatValue{Value: 0}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), ConstraintId: proto.String("float.gt"), Message: proto.String("value must be greater than 0"), }), @@ -60,7 +61,8 @@ func wrapperSuite() suites.Suite { "double/invalid": { Message: &cases.WrapperDouble{Val: &wrapperspb.DoubleValue{Value: 0}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("double.gt"), ConstraintId: proto.String("double.gt"), Message: proto.String("value must be greater than 0"), }), @@ -76,7 +78,8 @@ func wrapperSuite() suites.Suite { "int64/invalid": { Message: &cases.WrapperInt64{Val: &wrapperspb.Int64Value{Value: 0}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int64.gt"), ConstraintId: proto.String("int64.gt"), Message: proto.String("value must be greater than 0"), }), @@ -92,7 +95,8 @@ func wrapperSuite() suites.Suite { "int32/invalid": { Message: &cases.WrapperInt32{Val: &wrapperspb.Int32Value{Value: 0}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("int32.gt"), ConstraintId: proto.String("int32.gt"), Message: proto.String("value must be greater than 0"), }), @@ -108,7 +112,8 @@ func wrapperSuite() suites.Suite { "uint64/invalid": { Message: &cases.WrapperUInt64{Val: &wrapperspb.UInt64Value{Value: 0}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint64.gt"), ConstraintId: proto.String("uint64.gt"), Message: proto.String("value must be greater than 0"), }), @@ -124,7 +129,8 @@ func wrapperSuite() suites.Suite { "uint32/invalid": { Message: &cases.WrapperUInt32{Val: &wrapperspb.UInt32Value{Value: 0}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("uint32.gt"), ConstraintId: proto.String("uint32.gt"), Message: proto.String("value must be greater than 0"), }), @@ -140,7 +146,8 @@ func wrapperSuite() suites.Suite { "bool/invalid": { Message: &cases.WrapperBool{Val: &wrapperspb.BoolValue{Value: false}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bool.const"), ConstraintId: proto.String("bool.const"), Message: proto.String("value must equal true"), }), @@ -156,7 +163,8 @@ func wrapperSuite() suites.Suite { "string/invalid": { Message: &cases.WrapperString{Val: &wrapperspb.StringValue{Value: "fizzbuzz"}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.suffix"), ConstraintId: proto.String("string.suffix"), Message: proto.String("value does not have suffix `bar`"), }), @@ -172,7 +180,8 @@ func wrapperSuite() suites.Suite { "bytes/invalid": { Message: &cases.WrapperBytes{Val: &wrapperspb.BytesValue{Value: []byte("x")}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("bytes.min_len"), ConstraintId: proto.String("bytes.min_len"), Message: proto.String("value length must be at least 3 bytes"), }), @@ -184,7 +193,8 @@ func wrapperSuite() suites.Suite { "required/string/invalid": { Message: &cases.WrapperRequiredString{Val: &wrapperspb.StringValue{Value: "foo"}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.const"), ConstraintId: proto.String("string.const"), Message: proto.String("value must equal `bar`"), }), @@ -192,7 +202,8 @@ func wrapperSuite() suites.Suite { "required/string/empty/invalid": { Message: &cases.WrapperRequiredString{}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), ConstraintId: proto.String("required"), Message: proto.String("value is required"), }), @@ -204,14 +215,15 @@ func wrapperSuite() suites.Suite { "required/empty/string/invalid": { Message: &cases.WrapperRequiredEmptyString{Val: &wrapperspb.StringValue{Value: "foo"}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.const"), ConstraintId: proto.String("string.const"), Message: proto.String("value must equal ``"), }), }, "required/empty/string/empty/invalid": { Message: &cases.WrapperRequiredEmptyString{}, - Expected: results.Violations(&validate.Violation{FieldPath: proto.String("val"), ConstraintId: proto.String("required"), Message: proto.String("value is required")}), + Expected: results.Violations(&validate.Violation{Field: results.FieldPath("val"), Rule: results.FieldPath("required"), ConstraintId: proto.String("required"), Message: proto.String("value is required")}), }, "optional/string/uuid/valid": { Message: &cases.WrapperOptionalUuidString{Val: &wrapperspb.StringValue{Value: "8b72987b-024a-43b3-b4cf-647a1f925c5d"}}, @@ -224,7 +236,8 @@ func wrapperSuite() suites.Suite { "optional/string/uuid/invalid": { Message: &cases.WrapperOptionalUuidString{Val: &wrapperspb.StringValue{Value: "foo"}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("string.uuid"), ConstraintId: proto.String("string.uuid"), Message: proto.String("value must be a valid UUID"), }), @@ -236,7 +249,8 @@ func wrapperSuite() suites.Suite { "required/float/invalid": { Message: &cases.WrapperRequiredFloat{Val: &wrapperspb.FloatValue{Value: -5}}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("float.gt"), ConstraintId: proto.String("float.gt"), Message: proto.String("value must be greater than 0"), }), @@ -244,7 +258,8 @@ func wrapperSuite() suites.Suite { "required/float/empty/invalid": { Message: &cases.WrapperRequiredFloat{}, Expected: results.Violations(&validate.Violation{ - FieldPath: proto.String("val"), + Field: results.FieldPath("val"), + Rule: results.FieldPath("required"), ConstraintId: proto.String("required"), Message: proto.String("value is required"), }), diff --git a/tools/protovalidate-conformance/internal/fieldpath/fieldpath.go b/tools/protovalidate-conformance/internal/fieldpath/fieldpath.go new file mode 100644 index 00000000..bc67ac42 --- /dev/null +++ b/tools/protovalidate-conformance/internal/fieldpath/fieldpath.go @@ -0,0 +1,268 @@ +// 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. + +package fieldpath + +import ( + "errors" + "fmt" + "strconv" + "strings" + + "github.com/bufbuild/protovalidate/tools/internal/gen/buf/validate" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/descriptorpb" +) + +// Marshal takes a FieldPath and encodes it to a string-based dotted field path. +func Marshal(path *validate.FieldPath) string { + var result strings.Builder + if path == nil { + return "" + } + for i, element := range path.GetElements() { + if i > 0 { + result.WriteByte('.') + } + result.WriteString(element.GetFieldName()) + subscript := element.GetSubscript() + if subscript == nil { + continue + } + result.WriteByte('[') + switch value := subscript.(type) { + case *validate.FieldPathElement_Index: + result.WriteString(strconv.FormatUint(value.Index, 10)) + case *validate.FieldPathElement_BoolKey: + result.WriteString(strconv.FormatBool(value.BoolKey)) + case *validate.FieldPathElement_IntKey: + result.WriteString(strconv.FormatInt(value.IntKey, 10)) + case *validate.FieldPathElement_UintKey: + result.WriteString(strconv.FormatUint(value.UintKey, 10)) + case *validate.FieldPathElement_StringKey: + result.WriteString(strconv.Quote(value.StringKey)) + } + result.WriteByte(']') + } + return result.String() +} + +// Unmarshal parses a string-based dotted field path to a FieldPath. +func Unmarshal( + message protoreflect.MessageDescriptor, + path string, +) (*validate.FieldPath, error) { + var name, subscript string + var atEnd, isExt bool + var err error + result := &validate.FieldPath{} + for !atEnd { + name, subscript, path, atEnd, isExt = parsePathElement(path) + if name == "" { + return nil, errors.New("empty field name") + } + var descriptor protoreflect.FieldDescriptor + var oneOf protoreflect.OneofDescriptor + if isExt { + extension, err := protoregistry.GlobalTypes.FindExtensionByName(protoreflect.FullName(name)) + if err != nil { + return nil, fmt.Errorf("resolving extension: %w", err) + } + descriptor = extension.TypeDescriptor() + } else { + descriptor = message.Fields().ByTextName(name) + oneOf = message.Oneofs().ByName(protoreflect.Name(name)) + } + var element *validate.FieldPathElement + switch { + case descriptor != nil: + element = &validate.FieldPathElement{ + FieldNumber: proto.Int32(int32(descriptor.Number())), + FieldName: proto.String(descriptor.TextName()), + FieldType: descriptorpb.FieldDescriptorProto_Type(descriptor.Kind()).Enum(), + } + case oneOf != nil: + element = &validate.FieldPathElement{ + FieldName: proto.String(string(oneOf.Name())), + } + result.Elements = append(result.Elements, element) + continue + default: + return nil, fmt.Errorf("field %s not found", name) + } + result.Elements = append(result.Elements, element) + if subscript != "" { + descriptor, err = parseSubscript(descriptor, subscript, name, element) + if err != nil { + return nil, err + } + } else if descriptor.IsList() || descriptor.IsMap() { + if atEnd { + break + } + return nil, fmt.Errorf("missing subscript on field %s", name) + } + if descriptor.Message() != nil { + message = descriptor.Message() + } + } + return result, nil +} + +func parseSubscript( + descriptor protoreflect.FieldDescriptor, + subscript string, + name string, + element *validate.FieldPathElement, +) (protoreflect.FieldDescriptor, error) { + switch { + case descriptor.IsList(): + i, err := strconv.Atoi(subscript) + if err != nil { + return nil, fmt.Errorf("invalid list index: %s", subscript) + } + element.Subscript = &validate.FieldPathElement_Index{Index: uint64(i)} + case descriptor.IsMap(): + if err := parseMapKey(descriptor, subscript, element); err != nil { + return nil, err + } + element.KeyType = descriptorpb.FieldDescriptorProto_Type(descriptor.MapKey().Kind()).Enum() + element.ValueType = descriptorpb.FieldDescriptorProto_Type(descriptor.MapValue().Kind()).Enum() + descriptor = descriptor.MapValue() + default: + return nil, fmt.Errorf("unexpected subscript on field %s", name) + } + return descriptor, nil +} + +func parseMapKey( + mapDescriptor protoreflect.FieldDescriptor, + subscript string, + element *validate.FieldPathElement, +) error { + switch mapDescriptor.MapKey().Kind() { + case protoreflect.BoolKind: + if boolValue, err := strconv.ParseBool(subscript); err == nil { + element.Subscript = &validate.FieldPathElement_BoolKey{BoolKey: boolValue} + return nil + } + case protoreflect.Sint32Kind: + if intValue, err := strconv.ParseInt(subscript, 10, 32); err == nil { + element.Subscript = &validate.FieldPathElement_IntKey{IntKey: intValue} + return nil + } + case protoreflect.Sint64Kind: + if intValue, err := strconv.ParseInt(subscript, 10, 64); err == nil { + element.Subscript = &validate.FieldPathElement_IntKey{IntKey: intValue} + return nil + } + case protoreflect.Int32Kind, protoreflect.Sfixed32Kind: + if intValue, err := strconv.ParseInt(subscript, 10, 32); err == nil { + element.Subscript = &validate.FieldPathElement_IntKey{IntKey: intValue} + return nil + } + case protoreflect.Int64Kind, protoreflect.Sfixed64Kind: + if intValue, err := strconv.ParseInt(subscript, 10, 64); err == nil { + element.Subscript = &validate.FieldPathElement_IntKey{IntKey: intValue} + return nil + } + case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: + if intValue, err := strconv.ParseUint(subscript, 10, 32); err == nil { + element.Subscript = &validate.FieldPathElement_UintKey{UintKey: intValue} + return nil + } + case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: + if intValue, err := strconv.ParseUint(subscript, 10, 64); err == nil { + element.Subscript = &validate.FieldPathElement_UintKey{UintKey: intValue} + return nil + } + case protoreflect.StringKind: + if stringValue, err := strconv.Unquote(subscript); err == nil { + element.Subscript = &validate.FieldPathElement_StringKey{StringKey: stringValue} + return nil + } + case protoreflect.EnumKind, protoreflect.FloatKind, protoreflect.DoubleKind, + protoreflect.BytesKind, protoreflect.MessageKind, protoreflect.GroupKind: + fallthrough + default: + // This should not occur, but it might if the rules are relaxed in the + // future. + return fmt.Errorf("unsupported map key type: %s", mapDescriptor.MapKey().Kind()) + } + return fmt.Errorf("invalid map key: %s", subscript) +} + +// parsePathElement parses a single path element. +func parsePathElement(path string) (name, subscript, rest string, atEnd bool, isExt bool) { + // Scan extension name. + if len(path) > 0 && path[0] == '[' { + if i := strings.IndexByte(path, ']'); i >= 0 { + isExt = true + name, path = path[1:i], path[i+1:] + } + } + // Scan field name. + if !isExt { + if i := strings.IndexAny(path, ".["); i >= 0 { + name, path = path[:i], path[i:] + } else { + name, path = path, "" + } + } + // No subscript: At end of path. + if len(path) == 0 { + return name, "", path, true, isExt + } + // No subscript: At end of path element. + if path[0] == '.' { + return name, "", path[1:], false, isExt + } + // Malformed subscript + if len(path) == 1 || path[1] == '.' { + name, path = name+path[:1], path[1:] + return name, "", path, true, isExt + } + switch path[1] { + case ']': + // Empty subscript + name, path = name+path[:2], path[2:] + case '`', '"', '\'': + // String subscript: must scan string. + var err error + subscript, err = strconv.QuotedPrefix(path[1:]) + if err == nil { + path = path[len(subscript)+2:] + } + default: + // Other subscript; can skip to next ] + if i := strings.IndexByte(path, ']'); i >= 0 { + subscript, path = path[1:i], path[i+1:] + } else { + // Unterminated subscript + return name + path, "", "", true, isExt + } + } + // No subscript: At end of path. + if len(path) == 0 { + return name, subscript, path, true, isExt + } + // No subscript: At end of path element. + if path[0] == '.' { + return name, subscript, path[1:], false, isExt + } + // Malformed element + return name, subscript, path, false, isExt +} diff --git a/tools/protovalidate-conformance/internal/results/result.go b/tools/protovalidate-conformance/internal/results/result.go index 03da0582..938c1861 100644 --- a/tools/protovalidate-conformance/internal/results/result.go +++ b/tools/protovalidate-conformance/internal/results/result.go @@ -22,6 +22,9 @@ import ( "github.com/bufbuild/protovalidate/tools/internal/gen/buf/validate" "github.com/bufbuild/protovalidate/tools/internal/gen/buf/validate/conformance/harness" + "github.com/bufbuild/protovalidate/tools/protovalidate-conformance/internal/fieldpath" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" ) type Result interface { @@ -113,7 +116,15 @@ func (v violationsResult) String() string { if err.GetForKey() { forKey = " (key)" } - _, _ = fmt.Fprintf(bldr, "\n%s %2d. %s%s: %s", resultPadding, i+1, err.GetFieldPath(), forKey, err.GetConstraintId()) + violationPath := "" + if path := err.GetField(); path != nil { + violationPath = fieldpath.Marshal(path) + } + rulePath := "" + if path := err.GetRule(); path != nil { + rulePath = " (" + fieldpath.Marshal(path) + ")" + } + _, _ = fmt.Fprintf(bldr, "\n%s %2d. %s%s: %s%s", resultPadding, i+1, violationPath, forKey, err.GetConstraintId(), rulePath) _, _ = fmt.Fprintf(bldr, "\n%s %s", resultPadding, err.GetMessage()) } return bldr.String() @@ -133,9 +144,13 @@ func (v violationsResult) IsSuccessWith(other Result, options *harness.ResultOpt return false } for i := range len(want) { - matchingField := want[i].GetFieldPath() == got[i].GetFieldPath() && want[i].GetForKey() == got[i].GetForKey() + //nolint:staticcheck // Intentional use of deprecated field + matchingField := want[i].GetFieldPath() == got[i].GetFieldPath() && + proto.Equal(want[i].GetField(), got[i].GetField()) && + want[i].GetForKey() == got[i].GetForKey() + matchingRule := proto.Equal(want[i].GetRule(), got[i].GetRule()) matchingConstraint := want[i].GetConstraintId() == got[i].GetConstraintId() - if !matchingField || !matchingConstraint { + if !matchingField || !matchingRule || !matchingConstraint { return false } if options.GetStrictMessage() && len(want[i].GetMessage()) > 0 && @@ -226,8 +241,56 @@ func (u unexpectedErrorResult) IsSuccessWith(_ Result, _ *harness.ResultOptions) func SortViolations(violations []*validate.Violation) { slices.SortFunc(violations, func(a, b *validate.Violation) int { if a.GetConstraintId() == b.GetConstraintId() { - return cmp.Compare(a.GetFieldPath(), b.GetFieldPath()) + return cmp.Compare(fieldpath.Marshal(a.GetField()), fieldpath.Marshal(b.GetField())) } return cmp.Compare(a.GetConstraintId(), b.GetConstraintId()) }) } + +// FieldPath returns a placeholder field path. It will be expanded automatically +// when processing the results. +func FieldPath(fieldPath string) *validate.FieldPath { + return &validate.FieldPath{ + Elements: []*validate.FieldPathElement{{FieldName: &fieldPath}}, + } +} + +// HydrateFieldPaths expands placeholder field paths in the violations messages. +func HydrateFieldPaths( + descriptor protoreflect.MessageDescriptor, + result Result, +) error { + switch result := result.(type) { + case violationsResult: + violations := result.inner.GetValidationError() + if violations == nil { + break + } + for _, violation := range violations.GetViolations() { + if path := violation.GetField(); path != nil && len(path.GetElements()) > 0 { + var err error + //nolint:staticcheck // Intentional use of deprecated field + violation.FieldPath = proto.String(path.GetElements()[0].GetFieldName()) + violation.Field, err = fieldpath.Unmarshal( + descriptor, + path.GetElements()[0].GetFieldName(), + ) + if err != nil { + return fmt.Errorf("hydrating field path: %w", err) + } + } + if path := violation.GetRule(); path != nil && len(path.GetElements()) > 0 { + var err error + constraints := validate.FieldConstraints{} + violation.Rule, err = fieldpath.Unmarshal( + constraints.ProtoReflect().Descriptor(), + path.GetElements()[0].GetFieldName(), + ) + if err != nil { + return fmt.Errorf("hydrating rule path: %w", err) + } + } + } + } + return nil +} diff --git a/tools/protovalidate-conformance/internal/suites/suite.go b/tools/protovalidate-conformance/internal/suites/suite.go index 486c8e59..95b2f775 100644 --- a/tools/protovalidate-conformance/internal/suites/suite.go +++ b/tools/protovalidate-conformance/internal/suites/suite.go @@ -97,6 +97,12 @@ func (s Suite) ProcessResults( if err != nil { return err } + if err := results.HydrateFieldPaths( + testCase.Message.ProtoReflect().Descriptor(), + testCase.Expected, + ); err != nil { + return err + } out.AddCase(&harness.CaseResult{ Name: caseName, Success: testCase.Expected.IsSuccessWith(actual, options),