I want to define individual modules, which in turn would implement business rules for the app. I wanted to follow simple naming/namespacing solution like BusinessRule.WHO.WHAT. I don’t know if this matters but I’ve put them under server/user/businessRules directory. Here is is my business rule module:
BusinessRule = {};
BusinessRule.User = {};
BusinessRule.User.canUserBeAdded = (function () {
"use strict";
var result = {
isValid: true,
errors: []
};
function run() {
return result;
}
return {
run: run
};
}());
and this works but I don’t understand why these changes crash the app.
-
if I change it to:
BusinessRule = BusinessRule || {};
BusinessRule.User = {}; -
or this:
//BusinessRule = BusinessRule || {};
BusinessRule.User = {};
They all crash with “ReferenceError: BusinessRule is not defined” - why? What’s the proper way of doing this?