New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need to validate data when doing Table.update #33
Comments
I agree that we should validate this data. The reason data is currently only validated during create is because during update you can pass different pieces of data which are completely valid during update, but would not be valid when creating an initial record. Such as partial updates, removing params from dynamodb, and adding items to Sets. I'm sure there is a good solution for this, but I want to be careful that we don't over complicate things and potentially make it difficult to fully utilize the feature DynamoDB offers |
@ryanfitz I've got on similar issue this week and some coworkers have faced it too in the past. I've two different suggestions that could be implemented (I could open the PR if you prefer and don't have time to it). First one would be add an option like 'updateValidation' (false as default) and it would be able validation before update. The problem that I see on this feature is that it is a little bit intrusive. Would like to know your opinion. I'm adapting (not modifying the lib) the second solution over here as we've faced some problems... |
@viniciuskneves Yes, this issue need to be handled, an record update is important operation as much as create, so we must validate data before update. We should have separate mechanism to validate data on update eg. updateValidations() or validateOnUpdate(true) during schema. |
validation mechanism in vogels is incomplete without this +1 for this feature |
+1 for feature |
1 similar comment
+1 for feature |
+1 |
@sjungwirth I finally found you can access the table/schema by calling model.scan(), which returns an object with the table, which contains the schema object, which you can call validate. It's hacky but it seems the easiest way to access the object. |
@AaronHarris this is really helpful, thank you. While looking into what you said it looks like there is a reference to
|
The
Table.create
method uses joi to check that all of the supplied data is valid before attempting to serialize it and write it to the database (table.js line 116). However,Table.update
does not do any data validation. This can result in invalid data being saved to the db. It can also cause a crash since some of the serializer code assumes that it is working with valid data. (For example, if the user performs an update with an invalid Date, a later call toDate.toISOString
will raise an uncaught error.)The text was updated successfully, but these errors were encountered: