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

TypeError: Joi.lazy is not a function #2359

Closed
MortenHofft opened this issue Apr 25, 2020 · 2 comments
Closed

TypeError: Joi.lazy is not a function #2359

MortenHofft opened this issue Apr 25, 2020 · 2 comments
Labels
support Questions, discussions, and general support

Comments

@MortenHofft
Copy link

MortenHofft commented Apr 25, 2020

Support plan

  • which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise): none
  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: 13.7.0
  • module version with issue: "@hapi/joi": "^17.1.1",
  • last module version without issue:
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): standalone
  • any other relevant information:

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

I'm new the the library and was just trying the examples listed in the documentation. Everything I tried worked as expected, except the lazy example for recursive schemas. See example from docs below:

const Person = Joi.object({
  firstName: Joi.string().required(),
  lastName: Joi.string().required(),
  children: Joi.array().items(Joi.lazy(() => Person).description('Person schema'))
});

What was the result you got?

children: Joi.array().items(Joi.lazy(() => Person).description('Person schema'))
                                  ^
TypeError: Joi.lazy is not a function

What result did you expect?

That it worked. All you other examples from the documentation works as is. I think this is a bug, otherwise the documentation might benefit from an extra line explaining usage.

Thank you

@MortenHofft MortenHofft added the support Questions, discussions, and general support label Apr 25, 2020
@MortenHofft
Copy link
Author

Close - I'm on the wrong version of the docs. Sorry

@micalevisk
Copy link

For those who reach this issue somehow:

Remove Joi.lazy() type (use Joi.link() instead) (#1968)

v16.0.0 Release notes: #2037

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

2 participants