Skip to content

Fixed validation of server's Joi options#3520

Closed
jgburet wants to merge 1 commit intohapijs:masterfrom
Brigad:validationOptions/stripUnknown
Closed

Fixed validation of server's Joi options#3520
jgburet wants to merge 1 commit intohapijs:masterfrom
Brigad:validationOptions/stripUnknown

Conversation

@jgburet
Copy link
Copy Markdown

@jgburet jgburet commented Jun 9, 2017

I encountered an error when trying to pass this to my server:

// ...
{
  modify: true,
  options: {
    stripUnknown: {
      objects: true,
      arrays: false
    }
  }
}

...telling me stripUnknown didn't meet requirement of having peer modify set to true.

It happened the validation made in Hapi was asserting stripUnknown was matching the validation of modify: a boolean. However, the documentation specifies stripUnknwon can also take an object.

Just to make a remark about my commit; I'm kind of disappointed to provide the validations for the inner values of the object here because I feel like this is not the job it is intended to. Especially since I'm not doing it there as it is resolved later by Joi itself.
I would prefer to stick with a simple:

// ...
otherwise: Joi.boolean().only(false)

Any preference?

stripUnknown & modify coupling, when stripUnknown is having an object
@hueniverse hueniverse added this to the 16.4.4 milestone Jul 17, 2017
@hueniverse hueniverse self-assigned this Jul 17, 2017
@hueniverse hueniverse added the bug Bug or defect label Jul 17, 2017
@hueniverse
Copy link
Copy Markdown
Contributor

This was too complicated. I kept it simple.

@lock
Copy link
Copy Markdown

lock Bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@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

Successfully merging this pull request may close these issues.

2 participants