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

object().with using nested paths validates when it shouldn't in Joi 14 #1617

Closed
chrismessiah opened this issue Oct 21, 2018 · 2 comments
Closed
Labels
bug Bug or defect
Milestone

Comments

@chrismessiah
Copy link

Context

  • node version: v8.11.4
  • joi version: 14.0.0
  • environment: node
  • used with: standalone

What are you trying to achieve or the steps to reproduce ?

A new feature in Joi 14 is the ability to use nested paths in or/and/with (among others) as described in #1615. However according to my tests with seem to validate in an unexpected or faulty manner.

const schema = Joi.object().keys({
    a: {
      b: Joi.string()
    },
    c: {
      d: Joi.string()
    }
})
.with("a.b", "c.d");

So if a: {b: "..."} exists we want c: {d: "..."} to also exist.

Which result you had ?

If we have the following input

const data = {
  a: {
    b: "foo"
  }
};

Then the input is considered valid.

What did you expect ?

The input should not be valid as c.d does not exist.

@Marsup Marsup added the bug Bug or defect label Oct 21, 2018
@Marsup Marsup added this to the 14.0.1 milestone Oct 21, 2018
@Marsup Marsup closed this as completed in 59c8d23 Oct 22, 2018
@Marsup
Copy link
Collaborator

Marsup commented Oct 22, 2018

Thanks for the report!

@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect
Projects
None yet
Development

No branches or pull requests

2 participants