Skip to content
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

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

Merged
merged 2 commits into from
Oct 28, 2017

Conversation

rokoroku
Copy link
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

schema: Joi.alternatives(Joi.object(), Joi.array(), Joi.func()).allow(true, false),
status: Joi.object().pattern(/\d\d\d/, Joi.alternatives(Joi.object(), Joi.array(), Joi.func()).allow(true, false))
})
.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
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
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
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