helper/schema: use reflection to build []interface{}
This commit is contained in:
parent
17d29f7949
commit
ce42845acd
|
@ -224,10 +224,15 @@ func (m schemaMap) diffList(
|
|||
}
|
||||
}
|
||||
|
||||
vs, ok := v.([]interface{})
|
||||
if !ok {
|
||||
// We have to use reflection to build the []interface{} list
|
||||
rawV := reflect.ValueOf(v)
|
||||
if rawV.Kind() != reflect.Slice {
|
||||
return fmt.Errorf("%s: must be a list", k)
|
||||
}
|
||||
vs := make([]interface{}, rawV.Len())
|
||||
for i, _ := range vs {
|
||||
vs[i] = rawV.Index(i).Interface()
|
||||
}
|
||||
|
||||
// If this field is required, then it must also be non-empty
|
||||
if len(vs) == 0 && schema.Required {
|
||||
|
|
Loading…
Reference in New Issue