Skip to content
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

An expression attribute value used in expression is not defined #201

Open
sparkyfen opened this issue Jan 8, 2017 · 1 comment
Open

Comments

@sparkyfen
Copy link

sparkyfen commented Jan 8, 2017

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.

@utkarsh17ife
Copy link

any luck?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants