Rename validation hooks
Name should be "beforeValidate" and "afterValidate" to be consistent with other hook hames. This change doesnt break backward compatibility
This commit is contained in:
parent
b4813360c3
commit
48d78b71f6
10
lib/hooks.js
10
lib/hooks.js
|
@ -5,8 +5,8 @@ function Hookable() {
|
|||
};
|
||||
|
||||
Hookable.afterInitialize = null;
|
||||
Hookable.beforeValidation = null;
|
||||
Hookable.afterValidation = null;
|
||||
Hookable.beforeValidate = null;
|
||||
Hookable.afterValidate = null;
|
||||
Hookable.beforeSave = null;
|
||||
Hookable.afterSave = null;
|
||||
Hookable.beforeCreate = null;
|
||||
|
@ -18,8 +18,12 @@ Hookable.afterDestroy = null;
|
|||
|
||||
Hookable.prototype.trigger = function trigger(actionName, work, data) {
|
||||
var capitalizedName = capitalize(actionName);
|
||||
var afterHook = this.constructor["after" + capitalizedName];
|
||||
var beforeHook = this.constructor["before" + capitalizedName];
|
||||
var afterHook = this.constructor["after" + capitalizedName];
|
||||
if (actionName === 'validate') {
|
||||
beforeHook = beforeHook || this.constructor.beforeValidation;
|
||||
afterHook = afterHook || this.constructor.afterValidation;
|
||||
}
|
||||
var inst = this;
|
||||
|
||||
// we only call "before" hook when we have actual action (work) to perform
|
||||
|
|
Loading…
Reference in New Issue