@@ -151,6 +151,8 @@ func (lmktv listMapKeyTagValidator) GetValidations(context Context, _ []string,
151
151
return Validations {}, fmt .Errorf ("no field for JSON name %q" , payload )
152
152
} else if k := realType (memb .Type ).Kind ; k != types .Builtin {
153
153
return Validations {}, fmt .Errorf ("only primitive types can be list-map keys, not %s" , k )
154
+ } else if isPointer (memb .Type ) {
155
+ return Validations {}, fmt .Errorf ("pointer types cannot be list-map keys" )
154
156
} else {
155
157
fieldName = memb .Name
156
158
}
@@ -166,6 +168,16 @@ func (lmktv listMapKeyTagValidator) GetValidations(context Context, _ []string,
166
168
return Validations {}, nil
167
169
}
168
170
171
+ func isPointer (t * types.Type ) bool {
172
+ if t .Kind == types .Pointer {
173
+ return true
174
+ }
175
+ if t .Kind == types .Alias {
176
+ return isPointer (t .Underlying )
177
+ }
178
+ return false
179
+ }
180
+
169
181
func (lmktv listMapKeyTagValidator ) Docs () TagDoc {
170
182
doc := TagDoc {
171
183
Tag : lmktv .TagName (),
@@ -277,6 +289,8 @@ func (evtv eachValTagValidator) getListValidations(fldPath *field.Path, t *types
277
289
}
278
290
buf := strings.Builder {}
279
291
buf .WriteString ("return " )
292
+ // Note: this does not handle pointer fields, which are not
293
+ // supposed to be used as listMap keys.
280
294
for i , fld := range listMap .keyFields {
281
295
if i > 0 {
282
296
buf .WriteString (" && " )
0 commit comments