-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
featureNew functionality or improvementNew functionality or improvement
Milestone
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featureNew functionality or improvementNew functionality or improvement