Skip to content

Commit f75341c

Browse files
author
jennybuckley
committed
make removeItems handle empty sets better
1 parent 46c3c23 commit f75341c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

typed/remove.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ func (w *removingWalker) doList(t schema.List) (errs ValidationErrors) {
8686
newItems = append(newItems, l.Items[i])
8787
}
8888
l.Items = newItems
89+
if len(l.Items) == 0 {
90+
w.value.ListValue = nil
91+
w.value.Null = true
92+
}
8993
return nil
9094
}
9195

@@ -111,6 +115,10 @@ func (w *removingWalker) doMap(t schema.Map) ValidationErrors {
111115
newMap.Set(item.Name, m.Items[i].Value)
112116
}
113117
w.value.MapValue = newMap
118+
if len(w.value.MapValue.Items) == 0 {
119+
w.value.MapValue = nil
120+
w.value.Null = true
121+
}
114122
return nil
115123
}
116124

0 commit comments

Comments
 (0)