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

Joi.only is not a function #2111

Closed
rjdp opened this issue Sep 13, 2019 · 9 comments
Closed

Joi.only is not a function #2111

rjdp opened this issue Sep 13, 2019 · 9 comments
Assignees
Labels
non issue Issue is not a problem or requires changes
Milestone

Comments

@rjdp
Copy link

rjdp commented Sep 13, 2019

Context

  • node version: 10.16.3
  • joi version: 16.0.0
  • environment (node, browser): node
  • used with (hapi, standalone, ...): standalone
  • any other relevant information:

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

const schema = Joi.only("A").required()

Which result you had ?

TypeError: Joi.only is not a function

What did you expect ?

No exception

@Marsup Marsup added the non issue Issue is not a problem or requires changes label Sep 13, 2019
@Marsup Marsup self-assigned this Sep 13, 2019
@Marsup Marsup added the documentation Non-code related changes label Sep 13, 2019
@Marsup
Copy link
Collaborator

Marsup commented Sep 13, 2019

Yes, it's not available on the root, only on the types. I see you took it from the documentation, it's fixed.

@Marsup Marsup closed this as completed Sep 13, 2019
@rjdp
Copy link
Author

rjdp commented Sep 13, 2019

thought so, thanks for the quick update!

@rjdp
Copy link
Author

rjdp commented Sep 13, 2019

@Marsup but isn't .valid an alias of .any and .valid is present on the root

@Marsup
Copy link
Collaborator

Marsup commented Sep 13, 2019

Actually that's a fair point, my bad.

@Marsup Marsup reopened this Sep 13, 2019
@Marsup Marsup added bug Bug or defect and removed documentation Non-code related changes non issue Issue is not a problem or requires changes labels Sep 13, 2019
@rjdp
Copy link
Author

rjdp commented Sep 13, 2019

I think I will change my code to use .valid on types only and not on root, coz future fixes for this issue might break my code, that makes sense ?

@Marsup Marsup closed this as completed in c511ed5 Sep 13, 2019
@Marsup
Copy link
Collaborator

Marsup commented Sep 13, 2019

You can do that in the meantime. I'll let @hueniverse see if my patch makes sense with his vision but other methods are there so pretty sure this one should too. Anyway you won't see a release immediately so it's best you move on with the longer form.

@rjdp
Copy link
Author

rjdp commented Sep 13, 2019

much appreciated, thanks.

@hueniverse
Copy link
Contributor

only() is no longer used as an alias for valid(). This is a breaking change in v16.

@hueniverse hueniverse added non issue Issue is not a problem or requires changes and removed bug Bug or defect labels Sep 13, 2019
@hueniverse hueniverse added this to the 16.0.1 milestone Sep 13, 2019
@rjdp
Copy link
Author

rjdp commented Sep 13, 2019

missed to notice that in latest docs, thanks for clarification .

@lock lock bot locked as resolved and limited conversation to collaborators Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
non issue Issue is not a problem or requires changes
Projects
None yet
Development

No branches or pull requests

3 participants