File tree 2 files changed +4
-8
lines changed
2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ func translateRules(rules protoreflect.Message) *pv.FieldConstraints {
70
70
if msgRules .Get (msgDesc .Fields ().ByName ("required" )).Bool () {
71
71
constraints .Required = proto .Bool (true )
72
72
} else if msgRules .Get (msgDesc .Fields ().ByName ("skip" )).Bool () {
73
- constraints .Ignore = toPointer ( pv .Ignore_IGNORE_ALWAYS )
73
+ constraints .Ignore = pv .Ignore_IGNORE_ALWAYS . Enum ( )
74
74
}
75
75
}
76
76
@@ -105,7 +105,7 @@ func translateRule(
105
105
return true
106
106
} else if pgvDesc .Name () == "ignore_empty" && pgvDesc .Kind () == protoreflect .BoolKind && value .Bool () {
107
107
// old `ignore_empty` fields on the type rules need to be lifted to the top level
108
- constraints .Ignore = toPointer ( pv .Ignore_IGNORE_IF_UNPOPULATED )
108
+ constraints .Ignore = pv .Ignore_IGNORE_IF_UNPOPULATED . Enum ( )
109
109
return true
110
110
}
111
111
@@ -144,7 +144,3 @@ func translateRule(
144
144
}
145
145
return true
146
146
}
147
-
148
- func toPointer [T any ](value T ) * T {
149
- return & value
150
- }
Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ func TestTranslateFieldOptions(t *testing.T) {
113
113
msg : & examplev1.LegacySkipped {},
114
114
field : "x" ,
115
115
ex : & validate.FieldConstraints {
116
- Ignore : toPointer ( validate .Ignore_IGNORE_ALWAYS ),
116
+ Ignore : validate .Ignore_IGNORE_ALWAYS . Enum ( ),
117
117
},
118
118
},
119
119
{
@@ -200,7 +200,7 @@ func TestTranslateFieldOptions(t *testing.T) {
200
200
msg : & examplev1.LegacyIgnoreEmpty {},
201
201
field : "x" ,
202
202
ex : & validate.FieldConstraints {
203
- Ignore : toPointer ( validate .Ignore_IGNORE_IF_UNPOPULATED ),
203
+ Ignore : validate .Ignore_IGNORE_IF_UNPOPULATED . Enum ( ),
204
204
Type : & validate.FieldConstraints_Int32 {
205
205
Int32 : & validate.Int32Rules {
206
206
GreaterThan : & validate.Int32Rules_Gt {
You can’t perform that action at this time.
0 commit comments