Skip to content

Change default function second argument to full helpers (from prefs) #2189

@sekko27

Description

@sekko27

Support plan

  • which support plan is this issue covered by? Community
  • is this issue currently blocking your project? (yes/no): yes
  • is this issue affecting a production system? (yes/no): no

Context

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

How can we help?

Is it possible to pass the current state to the default value provider. It should be a help when using the pattern method (set default value based on the path for example)

const schema = Joi.object({})
  .pattern(
    /^.+$/, 
    Joi.object({
      type: Joi.string().default((ctx, options, state) => {
        // default value can be calculated based on state, for example env values
      })
    })
  );

Metadata

Metadata

Assignees

Labels

breaking changesChange that can breaking existing codefeatureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions