Skip to content

Commit

Permalink
Conformance: rule should contain path to custom constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
jchadwick-buf committed Nov 22, 2024
1 parent 23224b1 commit d44382b
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ func customSuite() suites.Suite {
Expected: results.Violations(
&validate.Violation{
Field: results.FieldPath("a"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("field_expression_scalar"),
},
&validate.Violation{
Field: results.FieldPath("b"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("field_expression_enum"),
},
),
Expand Down Expand Up @@ -125,25 +127,32 @@ func customSuite() suites.Suite {
Expected: results.Violations(
&validate.Violation{
Field: results.FieldPath("a"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("field_expression_scalar"),
},
&validate.Violation{
Field: results.FieldPath("b"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("field_expression_enum"),
},
&validate.Violation{
Field: results.FieldPath("c"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("field_expression_embed"),
},
&validate.Violation{
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"),
},
),
Expand Down
40 changes: 40 additions & 0 deletions tools/protovalidate-conformance/internal/cases/cases_ignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto2.message.ignore.empty"),
}),
},
Expand All @@ -345,6 +346,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto2.message.ignore.empty"),
}),
},
Expand All @@ -364,6 +366,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto2.message.ignore.empty"),
}),
},
Expand All @@ -373,6 +376,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto2.message.ignore.empty"),
}),
},
Expand All @@ -392,6 +396,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto2.message.ignore.empty"),
}),
},
Expand All @@ -413,6 +418,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto2.message.ignore.empty"),
}),
},
Expand All @@ -422,6 +428,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto2.message.ignore.empty"),
}),
},
Expand All @@ -437,6 +444,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto2.message.ignore.empty"),
}),
},
Expand All @@ -446,6 +454,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto2.message.ignore.empty"),
}),
},
Expand All @@ -461,6 +470,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto2.message.ignore.empty"),
}),
},
Expand Down Expand Up @@ -1068,6 +1078,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto3.message.ignore.empty"),
}),
},
Expand All @@ -1077,6 +1088,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto3.message.ignore.empty"),
}),
},
Expand All @@ -1096,6 +1108,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto3.message.ignore.empty"),
}),
},
Expand All @@ -1105,6 +1118,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto3.message.ignore.empty"),
}),
},
Expand All @@ -1124,6 +1138,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto3.message.ignore.empty"),
}),
},
Expand All @@ -1145,6 +1160,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto3.message.ignore.empty"),
}),
},
Expand All @@ -1154,6 +1170,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto3.message.ignore.empty"),
}),
},
Expand All @@ -1169,6 +1186,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto3.message.ignore.empty"),
}),
},
Expand All @@ -1178,6 +1196,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto3.message.ignore.empty"),
}),
},
Expand All @@ -1193,6 +1212,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto3.message.ignore.empty"),
}),
},
Expand Down Expand Up @@ -1912,6 +1932,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -1921,6 +1942,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -1940,6 +1962,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -1949,6 +1972,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -1968,6 +1992,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -1977,6 +2002,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -1996,6 +2022,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -2005,6 +2032,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -2024,6 +2052,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -2049,6 +2078,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -2070,6 +2100,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -2079,6 +2110,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -2094,6 +2126,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -2103,6 +2136,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -2118,6 +2152,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -2127,6 +2162,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -2142,6 +2178,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -2151,6 +2188,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -2166,6 +2204,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand All @@ -2187,6 +2226,7 @@ func ignoreSuite() suites.Suite {
},
Expected: results.Violations(&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("cel[0]"),
ConstraintId: proto.String("proto.editions.message.ignore.empty"),
}),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func ignoreEmptySuite() suites.Suite {
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"),
}),
},
Expand Down Expand Up @@ -199,6 +200,7 @@ func ignoreEmptySuite() suites.Suite {
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"),
}),
},
Expand Down Expand Up @@ -418,6 +420,7 @@ func ignoreEmptySuite() suites.Suite {
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"),
}),
},
Expand All @@ -433,6 +436,7 @@ func ignoreEmptySuite() suites.Suite {
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"),
}),
},
Expand Down
Loading

0 comments on commit d44382b

Please sign in to comment.