Closed jkav77 closed 7 years ago
The code looks great to me and the tests seem to validate this would fix the issue posted
Thanks for putting the time into this 👍
Hi, thanks for your PR. I'm really sorry I missed this. I'll hopefully have chance today to have a look.
I created a function
internals.validateItemFragment()
to check that attribute modifications requested with.update()
conform to the defined schema. This is more involved than just usingJoi.validate()
because.update()
is not guaranteed to receive all required attributes. For example, modifying one attribute of an existing item would only require specifying the Hash Key, Range Key (if there is one), and the attribute to modify. This works as I mentioned, but I would be interested in any feedback on the below. @Si1kIfY?A few issues/questions:
This method will not check the item has all
.isRequired()
attributes if you create a new item with.update()
. Rather it will ensure the fields specified match the schema. @deedw, any opinion on this?I didn't add anything to handle nested objects. The schema in the README does not cover nested objects or using the
Joi.object()
type. I am not really sure if this is possible or if people are doing that.Right now
.update()
validates the attributes it receives automatically. This would create problems if anyone was relying on.update()
to create items that don't match their schema.fixes #39