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

Set route validation bind context #3227

Merged
merged 2 commits into from Aug 21, 2016
Merged

Set route validation bind context #3227

merged 2 commits into from Aug 21, 2016

Conversation

@red-0ne
Copy link
Contributor

@red-0ne red-0ne commented Jun 30, 2016

fixes #3226

@red-0ne
Copy link
Contributor Author

@red-0ne red-0ne commented Jun 30, 2016

How can I fix lib/validation.js missing coverage on line(s): 142 ?

@Marsup
Copy link
Contributor

@Marsup Marsup commented Jun 30, 2016

By covering all the possibilities in your tests.

@nlf
Copy link
Member

@nlf nlf commented Jun 30, 2016

so that line looks like this:

const bind = request.route.settings.bind || request.route.realm || null;

in order to get full coverage, you need tests where request.route.settings.bind are both truthy and falsey, likewise for request.route.realm. think of it like making sure you can actually reach that final || null

@@ -139,7 +139,8 @@ internals.input = function (source, request, next) {

request._protect.run(postValidate, (exit) => {

return schema(request[source], localOptions, exit);
const bind = request.route.settings.bind || request.route.realm || null;
return schema.call(bind, request[source], localOptions, exit);
Copy link
Contributor

@arb arb Jun 30, 2016

Do we want call on hot code?

Copy link
Contributor

@Marsup Marsup Jun 30, 2016

call and apply are not slower than bound functions last time I checked, how would you do it ?

Copy link
Contributor

@arb arb Jun 30, 2016

Change the whole framework so you always pass a context object rather than relying on this 😄

But seriously, yeah there really isn't a way to do that other than call here.

remove unreachable condition when realm is falsy
@hueniverse hueniverse changed the title fix provide context to route custom validator Set route validation bind context Aug 21, 2016
@hueniverse hueniverse added the bug label Aug 21, 2016
@hueniverse hueniverse added this to the 15.0.0 milestone Aug 21, 2016
@hueniverse hueniverse self-assigned this Aug 21, 2016
@hueniverse hueniverse merged commit bfce5d4 into hapijs:master Aug 21, 2016
2 checks passed
hueniverse added a commit that referenced this issue Aug 21, 2016
@lock
Copy link

@lock 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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants