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

Added schema validation when creating a server method using object #2662

Merged
merged 2 commits into from Aug 7, 2015

Conversation

@mtharrison
Copy link
Contributor

@mtharrison mtharrison commented Jul 25, 2015

This is designed to catch simple mistakes like this:

server.method({
    name: 'myMethod',
    method: function () { ... },
    cache: {
        expiresIn: 1000
    }
});

which should really be:

server.method({
    name: 'myMethod',
    method: function () { ... },
    options: {
        cache: {
            expiresIn: 1000
        }
    }
});
@@ -274,6 +274,13 @@ internals.method = Joi.object({
});


internals.methodObject = Joi.object({
name: Joi.string(),
Copy link
Contributor

@Marsup Marsup Jul 25, 2015

Shouldn't name and method be required ?

Copy link
Contributor Author

@mtharrison mtharrison Jul 25, 2015

Yes. At the moment that's still taken care of here:

https://github.com/hapijs/hapi/blob/master/lib/methods.js#L42-L43

But I can add it to this schema too to be more explicit about it.

@AdriVanHoudt
Copy link
Contributor

@AdriVanHoudt AdriVanHoudt commented Jul 27, 2015

👍

@netei
Copy link

@netei netei commented Jul 27, 2015

Could be usefull indead

@hueniverse hueniverse added this to the 9.0.0 milestone Aug 7, 2015
@hueniverse hueniverse self-assigned this Aug 7, 2015
hueniverse pushed a commit that referenced this issue Aug 7, 2015
Added schema validation when creating a server method using object
@hueniverse hueniverse merged commit ff97278 into hapijs:master Aug 7, 2015
1 check passed
@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.

None yet

5 participants