aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2019-04-22 13:56:08 +0200
committerPřemysl Janouch <p@janouch.name>2019-04-22 13:56:08 +0200
commit81927e9017deb911d5d52461317bfad8a0b14406 (patch)
tree02c3bd07430fb76dc416253aac16f7c054424d42
parent88560a8fbf6d0c8bac45a07c29bd4ab23b50968b (diff)
downloadsklad-81927e9017deb911d5d52461317bfad8a0b14406.tar.gz
sklad-81927e9017deb911d5d52461317bfad8a0b14406.tar.xz
sklad-81927e9017deb911d5d52461317bfad8a0b14406.zip
sklad: proper validations on container update
-rw-r--r--cmd/sklad/db.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/cmd/sklad/db.go b/cmd/sklad/db.go
index b58a5f2..fc79f0f 100644
--- a/cmd/sklad/db.go
+++ b/cmd/sklad/db.go
@@ -205,6 +205,13 @@ func dbContainerCreate(c *Container) error {
}
func dbContainerUpdate(c *Container, updated Container) error {
+ if _, ok := indexSeries[updated.Series]; !ok {
+ return errNoSuchSeries
+ }
+ if updated.Parent != "" && indexContainer[updated.Parent] == nil {
+ return errNoSuchContainer
+ }
+
newID := updated.Id()
if updated.Series != c.Series && len(c.Children()) > 0 {
return errCannotChangeSeriesNotEmpty