Skip to content

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

Merged
hueniverse merged 2 commits intohapijs:masterfrom
mtharrison:master
Aug 7, 2015
Merged

Added schema validation when creating a server method using object#2662
hueniverse merged 2 commits intohapijs:masterfrom
mtharrison:master

Conversation

@mtharrison
Copy link
Copy Markdown
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
        }
    }
});

lib/schema.js Outdated
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

👍

@netei
Copy link
Copy Markdown

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
Copy Markdown

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.

5 participants