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

Empty object in Dynamo DB when using conditional validation #224

Open
aaronjhoffman opened this issue Oct 16, 2017 · 0 comments
Open

Empty object in Dynamo DB when using conditional validation #224

aaronjhoffman opened this issue Oct 16, 2017 · 0 comments

Comments

@aaronjhoffman
Copy link

I've been trying to add conditional validation in my schema using joi.when as following:

{
  id: vogels.types.uuid(),
  type: Joi.string().valid(['a','b']).required(),
  time: Joi.object().keys({
    start: Joi.date().required(),
    end: Joi.date(),
  }).required().when('type', { is: 'a', then: Joi.object({ end: Joi.required()}), otherwise: Joi.object({ end: Joi.valid(null)})}),
}

When trying to create new object using mytable.Create I'm getting result back correctly although in the db the field "time" is empty object {}

I've tested the data with the Joi schema and it's all valid, and as I said, even Vogels return the "saved" object correctly - but still in the DB the field is empty.
When I'm removing the "when" condition, it's all working perfectly and the field is populated correctly in the DB.

Any help would be greatly appreciated on this.

Thanks in advance

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

1 participant