-
Notifications
You must be signed in to change notification settings - Fork 22
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
string Attributes are not allowed to be empty #7
Comments
Have a minimal repro case? |
Oh, I see what you mean, it shouldn't allow empty strings. |
Yes - API doesn't allow empty strings. On 6 April 2016 at 14:30, Frankie Bagnardi notifications@github.com wrote:
Bryan Crotaz |
The library avoids doing data validations. Invalid data in a DynamoDB request results in an error response thereby indicating the invalid data. Could you make use of the error response to capture invalid data? Including data checks/validations in this library would help detect invalid data earlier - i.e. before making an HTTP API request. However in that case the library would need to validate data exactly as DynamoDB does - else the feature might not be worth having. Does your use case need data validation to be done before making a DynamoDB API call? ps: There was a line in the docs mentioning that this library doesn't perform such checks. This line currently seems to be missing in the docs. |
@BryanCrotaz thanks for the pull request and test case. As you mentioned, this library detects an empty string as The idea is to let this library do nothing more than help represent your data. If the data is invalid it would be better to let the application handle it. Nonetheless, to attempt to do what you require, you can now make use of a hook. The hook Suppose your application needs an empty string to be detected as
See examples/05-reconcile-data.js for a full example. The reconcile function gives the application an opportunity to reconcile data. A custom reconcile function may be used instead of This change is only in git, not yet moved to the NPM repo. Let me know what you think. I hope this is useful for your use case. @brigand would be great if you have any suggestions or alternate way to do this. Thanks. |
The thing is that all applications need this - Dynamo will never accept {S: ''} - we're putting a burden on developers that doesn't need to be there |
I'd be happy with a compromise of making |
If setting the global var seems an unnecessary step, another solution would This way, both approaches are supported.
|
I'm mostly just concerned that this should be a library that "just
works". The default out of the box behaviour should enable the user to
load and save data to and from Dynamo without having to think about
it.
|
When as a developer would you choose not to use vwrap / cwrap?
|
My point is to maintain separation of concerns. This library should only be To me, some reasons not to convert an Empty string into null are the
Maybe its better to let the application decide what to do if an empty Ideally if you want to convert an Empty string into null before writing it Coerce(my data); // do stuff such as covert empty string to null This is just my approach. Maybe having vWrap() separate from wrap() is a way to let both approaches Besides, changing the behaviour of wrap() might break applications using
|
The problem is that Another option would be to create a custom structure for representing empty strings. For example, you could convert |
Your uuid approach is interesting. Using it to overcome restrictions would
|
Just ran into this too and saw the reconcile change was reverted. I ended up writing some code to remove empty strings from my objects before putting them into .wrap(). Just thought I'd leave it for the next passer by.
|
@bfsmith this is late response, but you can use |
* commit 'b13c0d2f8a97fdd4fc92b53163377a7dcb1a2cb7': add es6 exports Fix tests (can't run on windows!) add test for wrapping empty string as null Fix Issue kayomarz#7
API limitation
The text was updated successfully, but these errors were encountered: