feature(util) add checkArgs

This commit is contained in:
coderaiser 2014-05-26 09:42:49 -04:00
parent 4a4ab12a5b
commit d77ac56f0f
2 changed files with 30 additions and 7 deletions

View file

@ -327,13 +327,18 @@ var Util;
* @param url - адрес каталога
*/
function getPathLink(url, template) {
var pathHTML = '',
path = '/',
namesRaw = url.split('/')
.slice(1, -1),
names = [].concat('/', namesRaw),
length = names.length - 1;
var namesRaw, names, length,
pathHTML = '',
path = '/';
Util.checkArgs(arguments, ['url', 'template']);
namesRaw = url.split('/')
.slice(1, -1),
names = [].concat('/', namesRaw),
length = names.length - 1;
names.forEach(function(name, index) {
var slash = '',

View file

@ -59,6 +59,24 @@
return !!isMatch;
};
this.checkArgs = function(argsParam, names) {
var error,
msg = '',
i = 0,
n = names.length,
template = '{{ name }} coud not be empty!';
for (i = 0; i < n; i++)
if (!argsParam[i]) {
msg = Util.render(template, {
name: names[i]
});
error = new Error(msg);
throw(error);
}
};
/**
* Check is Properties exists and they are true if neaded
*