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

@rokoroku rokoroku commented Oct 27, 2017

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

@hueniverse hueniverse Oct 27, 2017

Do you need to keep the forbidden as alternative?

Copy link
Contributor Author

@rokoroku rokoroku Oct 28, 2017

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

@hueniverse hueniverse Oct 28, 2017

It's not needed because the default is optional.

@hueniverse hueniverse self-assigned this Oct 28, 2017
@hueniverse hueniverse added the bug 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
2 checks passed
hueniverse added a commit that referenced this issue Oct 28, 2017
rokoroku added a commit to rokoroku/hapi that referenced this issue Apr 23, 2018
@rokoroku rokoroku mentioned this pull request Apr 23, 2018
rokoroku added a commit to rokoroku/hapi that referenced this issue Apr 23, 2018
rokoroku added a commit to rokoroku/hapi that referenced this issue Apr 23, 2018
rokoroku added a commit to rokoroku/hapi that referenced this issue Apr 23, 2018
rokoroku added a commit to rokoroku/hapi that referenced this issue Apr 23, 2018
rokoroku added a commit to rokoroku/hapi that referenced this issue Apr 23, 2018
@rokoroku rokoroku deleted the patch-1 branch Oct 28, 2019
@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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants