Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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