Skip to content

Joi.defaults(): Cannot default object type #1278

@rokoroku

Description

@rokoroku

Context

  • node version: 8
  • joi version: (pre) 11.0
  • environment (node, browser):
  • used with (hapi, standalone, ...):
  • any other relevant information:

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

Describe your issue here, include schemas and inputs you are validating if needed.

const defaultJoi = Joi.defaults((schema) => {
  switch(schema.type) {
    case 'object': // it cannot be reached, since object schema's type is function.
      ...
  }
})

// this is not defaulted.
defaultJoi.object()

What did you expect ?

#1256 introduces Joi.defaults() feature, however,
there is a conflict in joi's API: type getter & Joi.object().type()

Type getter or mapping function of Joi.defaults() should be redesigned.

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions