From 8a46d545f05d40cb84dba5eceb22db7b75e585a8 Mon Sep 17 00:00:00 2001 From: evanshriner Date: Mon, 20 May 2019 14:15:02 -0400 Subject: [PATCH] Validate update against Schema Currently, update() does not validate against the associated Table schema. I do not believe this should be the desired behavior. --- lib/table.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/table.js b/lib/table.js index fb2b4e6..137847f 100644 --- a/lib/table.js +++ b/lib/table.js @@ -288,6 +288,12 @@ Table.prototype.update = function (item, options, callback) { return callback(err); } + var result = self.schema.validate(data); + + if(result.error) { + return callback(result.error); + } + var hashKey = data[self.schema.hashKey]; var rangeKey = data[self.schema.rangeKey] || null;