Skip to content

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

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

Closed
rokoroku opened this issue Aug 20, 2017 · 1 comment
Closed

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

rokoroku opened this issue Aug 20, 2017 · 1 comment
Assignees
Labels
bug Bug or defect
Milestone

Comments

@rokoroku
Copy link
Contributor

rokoroku commented Aug 20, 2017

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.

@Marsup Marsup added the bug Bug or defect label Aug 26, 2017
@Marsup Marsup self-assigned this Aug 26, 2017
@Marsup Marsup added this to the 11.0.0 milestone Aug 26, 2017
@Marsup Marsup closed this as completed in a281211 Aug 26, 2017
@Marsup
Copy link
Collaborator

Marsup commented Aug 26, 2017

Good spot, thanks for the report !

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect
Projects
None yet
Development

No branches or pull requests

2 participants