func TestMapToPtrStruct(t *testing.T) {
s := struct {
// pointer to struct
M map[string]*struct {
ID string
}
}{}
vals := url.Values{
"M[key].ID": []string{"M[key].ID"},
}
dec := formam.NewDecoder(nil)
if err := dec.Decode(vals, &s); err != nil {
t.Fatalf("error when decode %s", err)
}
if v, ok := s.M["key"]; !ok {
t.Error("The key \"key\" in M does not exists")
} else if v.ID != "M[key].ID" {
t.Error("The value in key \"key\" of M is incorrect")
}
}
Expected: no error
Actual:error when decode formam: unsupported type; maybe include it the UnmarshalText interface or register it using custom type?
Code to reproduce:
Expected: no error Actual:
error when decode formam: unsupported type; maybe include it the UnmarshalText interface or register it using custom type?