Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mikermcneil authored Jun 14, 2016
1 parent ac91e9d commit 2e76dac
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ module.exports = function(sails) {

return function Hook(definition) {

// A few sanity checks to make sure te provided definition does not contain any reserved properties.
if (!_.isObject(definition)) {
// This particular behavior can be made a bit less genteel in future versions (it is currently
// forgiving for backwards compatibility)
definition = definition || {};
}

if (_.isFunction(definition.config)) {
throw new Error('Error defining hook: `config` is a reserved property and cannot be used as a custom hook method.');
}
if (_.isFunction(definition.middleware)) {
throw new Error('Error defining hook: `middleware` is a reserved property and cannot be used as a custom hook method.');
}



/**
Expand Down Expand Up @@ -159,7 +173,9 @@ module.exports = function(sails) {


/**
* Ensure that a hook definition has the required properties
* Ensure that a hook definition has the required properties.
*
* @returns {Dictionary} [coerced hook definition]
* @api private
*/

Expand Down

0 comments on commit 2e76dac

Please sign in to comment.