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

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

Choose a reason for hiding this comment

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

Shouldn't name and method be required ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

👍

@netei
Copy link

netei commented Jul 27, 2015

Could be usefull indead

@mtharrison mtharrison added the feature New functionality or improvement label Aug 4, 2015
@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 pull request Aug 7, 2015
Added schema validation when creating a server method using object
@hueniverse hueniverse merged commit ff97278 into hapijs:master Aug 7, 2015
@lock
Copy link

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
feature New functionality or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants