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:
Anatoliy Chakkaev 2013-03-28 15:23:31 +04:00
parent b4813360c3
commit 48d78b71f6
1 changed files with 7 additions and 3 deletions

View File

@ -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