Skip to content

Commit

Permalink
fix(hooks): fix bad validation behavior
Browse files Browse the repository at this point in the history
couple of commits back a bad validation behavior regarding hook events was added, so fixed it
  • Loading branch information
thetutlage committed Jul 30, 2017
1 parent 98a318a commit 1b3a0d5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Lucid/Hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ class Hooks {
update: 'save'
}

/**
* The events array of aliases, just required
* for validation purposes
*
* @type {Array}
*/
this._aliasEvents = _.values(this._aliases)

/**
* A map of handlers to be called for each event
*
Expand Down Expand Up @@ -65,7 +73,7 @@ class Hooks {
* ```
*/
addHandler (event, handler, name) {
if (!this._events[event]) {
if (_.includes(this._events[event]) && !_.includes(this._aliasEvents, event)) {
throw CE.InvalidArgumentException.invalidParameter(`${event} is not a valid hook event`)
}
this._handlers[event] = this._handlers[event] || []
Expand Down

0 comments on commit 1b3a0d5

Please sign in to comment.