diff options
author | Přemysl Janouch <p@janouch.name> | 2019-04-22 13:56:08 +0200 |
---|---|---|
committer | Přemysl Janouch <p@janouch.name> | 2019-04-22 13:56:08 +0200 |
commit | 81927e9017deb911d5d52461317bfad8a0b14406 (patch) | |
tree | 02c3bd07430fb76dc416253aac16f7c054424d42 /cmd | |
parent | 88560a8fbf6d0c8bac45a07c29bd4ab23b50968b (diff) | |
download | sklad-81927e9017deb911d5d52461317bfad8a0b14406.tar.gz sklad-81927e9017deb911d5d52461317bfad8a0b14406.tar.xz sklad-81927e9017deb911d5d52461317bfad8a0b14406.zip |
sklad: proper validations on container update
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/sklad/db.go | 7 |
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 |