From 3974bf7ec7f8b53fc3321c969c56ea40209aecce Mon Sep 17 00:00:00 2001 From: Alfredo Guzman Date: Fri, 8 Apr 2016 13:20:42 -0500 Subject: [PATCH] Validation in Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Considero que la validación se debe aplicar antes de actualizar, de la misma forma como se hace en "create" --- lib/table.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/table.js b/lib/table.js index 66a96fb..4aa646f 100644 --- a/lib/table.js +++ b/lib/table.js @@ -256,7 +256,13 @@ Table.prototype.update = function (item, options, callback) { if(err) { 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;