Skip to content

Loosen sample and modify peer validator in the routeBase schema#3663

Merged
hueniverse merged 2 commits into
hapijs:masterfrom
rokoroku:patch-1
Oct 28, 2017
Merged

Loosen sample and modify peer validator in the routeBase schema#3663
hueniverse merged 2 commits into
hapijs:masterfrom
rokoroku:patch-1

Conversation

@rokoroku
Copy link
Copy Markdown
Contributor

It fixes #3567

  • Make routeBase schema allows sample props when modify is set to false
  • Make options.stripUnknown assertion allows false value when modify is set to false

Comment thread lib/config.js
.default()
.without('modify', 'sample')
.assert('options.stripUnknown', Joi.when('modify', { is: true, otherwise: Joi.forbidden() }), 'meet requirement of having peer modify set to true'),
.assert('options.stripUnknown', Joi.when('modify', { is: true, otherwise: [Joi.boolean().valid(false), Joi.forbidden()] }), 'meet requirement of having peer modify set to true'),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to keep the forbidden as alternative?

Copy link
Copy Markdown
Contributor Author

@rokoroku rokoroku Oct 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just keep the existing code while allowing "false" value.

Do you want me to remove the forbidden as an alternative here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed because the default is optional.

@hueniverse hueniverse self-assigned this Oct 28, 2017
@hueniverse hueniverse added the bug Bug or defect label Oct 28, 2017
@hueniverse hueniverse added this to the 17.0.0 milestone Oct 28, 2017
@hueniverse hueniverse merged commit d9b3134 into hapijs:master Oct 28, 2017
hueniverse added a commit that referenced this pull request Oct 28, 2017
rokoroku added a commit to rokoroku/hapi that referenced this pull request Apr 23, 2018
@rokoroku rokoroku mentioned this pull request Apr 23, 2018
rokoroku added a commit to rokoroku/hapi that referenced this pull request Apr 23, 2018
rokoroku added a commit to rokoroku/hapi that referenced this pull request Apr 23, 2018
rokoroku added a commit to rokoroku/hapi that referenced this pull request Apr 23, 2018
rokoroku added a commit to rokoroku/hapi that referenced this pull request Apr 23, 2018
rokoroku added a commit to rokoroku/hapi that referenced this pull request Apr 23, 2018
@rokoroku rokoroku deleted the patch-1 branch October 28, 2019 00:21
@lock lock Bot locked as resolved and limited conversation to collaborators Apr 25, 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.

response validate options for 'modify' and 'sample' is too strict

2 participants