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

Add the ability to extend all types in place #2219

Closed
nlf opened this issue Nov 13, 2019 · 0 comments
Closed

Add the ability to extend all types in place #2219

nlf opened this issue Nov 13, 2019 · 0 comments
Assignees
Labels
feature New functionality or improvement
Milestone

Comments

@nlf
Copy link
Member

nlf commented Nov 13, 2019

Support plan

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

Context

  • node version: 12.x
  • module version: 16.x
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): standalone
  • any other relevant information:

What problem are you trying to solve?

I'm attempting to add a rule to all existing types at the same time. The specific rule I'd like to add is an .env() method such that I could do things like:

const config = Joi.object({
  port: Joi.number().integer().env('PORT').default(8000),
  host: Joi.string().env('HOST').default('127.0.0.1')
});

The idea being if the given environment variable is defined, its value will be used, otherwise it will fall back to the default behavior. Obviously this use case can be implemented in other ways but I think the overall idea behind this feature request has more value.

Do you have a new or modified API suggestion to solve the problem?

Nothing concrete, but some variation of the input passed to .extend() would probably make sense. Perhaps allowing to omit the name and base properties in favor of some flag indicating the desire to extend all existing types.

@nlf nlf added the feature New functionality or improvement label Nov 13, 2019
@hueniverse hueniverse self-assigned this Nov 13, 2019
@hueniverse hueniverse added this to the 17.0.0 milestone Jan 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

2 participants