An expression attribute value used in expression is not defined
Context
- node version: 6.2.0
- vogels version: ^2.2.0
- environment (node, browser): Node
- used with (hapi, standalone, ...):
expressjs ~4.14.0,joi ^10.1.0,express-validation ^1.0.1 - any other relevant information:
What are you trying to achieve or the steps to reproduce ?
I am trying to have the following work:
When I have a boolean called private who is default, if its provided as true, I want to expect a password to be required with a min length of 6, otherwise, I don't want to accept a password.
My input in the request:
{
...
private: false
...
}
Here is what I have for the initial input validation using express-validation:
{
....
private: Joi.boolean().default(false),
password: Joi.string().when('private', {is: true, then: Joi.string().min(6).required(), otherwise: Joi.forbidden()}),
...
}
The section above passes validation, however, I have also defined my DB schema using vogels:
vogels.define('Foo' {
...
private: Joi.boolean(),
password: Joi.string().allow(null).optional(),
...
});
I've also tried password: Joi.string() and password: Joi.string().optional() but they result in the same response.
If I pass the password field in the input with private I get the expected password is not allowed and if I set private to true, everything is fine. Its just when I don't pass the password field which results in the below error.
Which result you had ?
I get the following:
{ [ValidationException: Invalid UpdateExpression: An expression attribute value used in expression is not defined; attribute value: :password] message: 'Invalid UpdateExpression: An expression attribute value used in expression is not defined; attribute value: :password', code: 'ValidationException', time: Sun Jan 08 2017 22:38:17 GMT+0000 (UTC), requestId: 'REDACTED', statusCode: 400, retryable: false, retryDelay: 0 }
What did you expect ?
A successful update to the database.
any luck?