validateArgumentType: function()

in src/modules/utils.js [8:44]


    validateArgumentType: function (arg, argType, customExceptionType, customExceptionMessage, customExceptionObject) {
        var invalidArg = false,
            msg;

        switch (argType) {
            case 'array':
                if (!(arg instanceof Array)) {
                    invalidArg = true;
                }
                break;
            case 'date':
                if (!(arg instanceof Date)) {
                    invalidArg = true;
                }
                break;
            case 'integer':
                if (typeof arg === 'number') {
                    if (arg !== Math.floor(arg)) {
                        invalidArg = true;
                    }
                }
                else {
                    invalidArg = true;
                }
                break;
            default:
                if (typeof arg !== argType) {
                    invalidArg = true;
                }
                break;
        }

        if (invalidArg) {
            msg = customExceptionMessage + ('\n\nInvalid Argument type. argument: ' + arg + ' ==> was expected to be of type: ' + argType);
            exception.raise((customExceptionType || exception.types.ArgumentType), msg, customExceptionObject);
        }
    },