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

Feature Request: lazy once #1258

Closed
rokoroku opened this issue Jul 25, 2017 · 2 comments
Closed

Feature Request: lazy once #1258

rokoroku opened this issue Jul 25, 2017 · 2 comments
Assignees
Labels
breaking changes Change that can breaking existing code feature New functionality or improvement
Milestone

Comments

@rokoroku
Copy link
Contributor

rokoroku commented Jul 25, 2017

Context

  • node version: 6.9
  • joi version: 10.6.1
const schema = Joi.lazy(() => Joi.any()).once()

Since fn for Joi.lazy(fn) should return joi schema, it's okay to be called once to avoid unnecessary overhead.

(+) My other need is describing lazily-loaded schema with Joi.describe().
If lazy.once() replace the schema as lazily loaded schema itself, we can now describe the lazy schema as well. (Could it be another feature request for Joi.describe()? )

@Marsup
Copy link
Collaborator

Marsup commented Jul 25, 2017

once could be a thing, but it's probably not a good idea for description as lazy is often used for cyclic or recursive patterns, so this would obviously result in endless descriptions.

@rokoroku
Copy link
Contributor Author

rokoroku commented Jul 26, 2017

@Marsup what about adding deep options to Joi.describe() ? Then it gives a chance to avoid cyclic schema

Come to think of it, describing lazy schema may harmful in many situations, and it's not likely to be widely used.

@Marsup Marsup added the request label Jul 26, 2017
@Marsup Marsup added this to the 14.0.0 milestone Aug 13, 2018
@Marsup Marsup added the breaking changes Change that can breaking existing code label Aug 13, 2018
@Marsup Marsup self-assigned this Aug 13, 2018
@Marsup Marsup closed this as completed in f225d91 Oct 14, 2018
@hueniverse hueniverse added feature New functionality or improvement and removed request labels Sep 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking changes Change that can breaking existing code feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

3 participants