From c569e6543f79e76f33b51250c69a222c3353d58f Mon Sep 17 00:00:00 2001 From: "j.goderbauer" <j.goderbauer@adito.de> Date: Fri, 7 Dec 2018 14:08:28 +0100 Subject: [PATCH] enabled comm validation --- process/Comm_lib/process.js | 134 ++++++++++++++++++------------------ 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/process/Comm_lib/process.js b/process/Comm_lib/process.js index cbc68a643d..1fc1ecff24 100644 --- a/process/Comm_lib/process.js +++ b/process/Comm_lib/process.js @@ -1,67 +1,67 @@ -import("system.translate"); -import("system.net"); -import("system.mail"); -import("system.cti"); - - -/** - * provides static methods for validation of communication data - * do not create an instance of this - * - * @class - */ -function CommValidationUtil() { -} - -/** - * creates a function depending on a given COMM-category (like PHONE, EMAIL, etc.) or null if no validation-function was defined for the given category - * @param {string} commCategory category that determines which function shall be created, e.g. "EMAIL" - * @return {function} function that receives the following arguments: - * <br/> - commAddress - * <br/> - extensions - * <br/>the function has to return null if everything is OK or a value with details if validation failed - */ -CommValidationUtil.makeValidationFn = function (commCategory){ - var callbackFn; - - switch (commCategory) { - case "EMAIL": - callbackFn = function (addrValue){ -// if (!mail.isValidMailAddress(addrValue)) //TODO: enable JDito-methods -// return translate.text("no valid mail-address format"); - return null; - } - break; - case "LINK": - callbackFn = function (addrValue){ -// if (!net.isValidUrl(addrValue, ["http", "https"]))//TODO: enable JDito-methods -// return translate.text("no valid format"); - return null; - } - break; - case "TELEPHONE": - callbackFn = function (addrValue, ext){ - var country = null; - if (addrValue[0] != "+") //if the number starts with a country-identifier (e.g. +49) no country needs to be specified - country = ext.countryCode; -// if (!cti.isValidPhoneNumber(addrValue, country))//TODO: enable JDito-methods -// return translate.text("no valid phone number"); - return null; - } - break; - default: - callbackFn = null; - break; - } - return callbackFn; -} - -/** - * returns a blueprint for validation extensions; these extensions are needed for validating comm data and can be passed to other functions - * @return {object} a object with properties that have a specific default value; normally you want to overwrite that value - */ -CommValidationUtil.getExtensionsBlueprint = function(){ - return { - countryCode: null - }; -} +import("system.translate"); +import("system.net"); +import("system.mail"); +import("system.cti"); + + +/** + * provides static methods for validation of communication data + * do not create an instance of this + * + * @class + */ +function CommValidationUtil() { +} + +/** + * creates a function depending on a given COMM-category (like PHONE, EMAIL, etc.) or null if no validation-function was defined for the given category + * @param {string} commCategory category that determines which function shall be created, e.g. "EMAIL" + * @return {function} function that receives the following arguments: + * <br/> - commAddress + * <br/> - extensions + * <br/>the function has to return null if everything is OK or a value with details if validation failed + */ +CommValidationUtil.makeValidationFn = function (commCategory){ + var callbackFn; + + switch (commCategory) { + case "EMAIL": + callbackFn = function (addrValue){ + if (!mail.isValidMailAddress(addrValue)) //TODO: enable JDito-methods + return translate.text("no valid mail-address format"); + return null; + } + break; + case "LINK": + callbackFn = function (addrValue){ + if (!net.isValidUrl(addrValue, ["http", "https"]))//TODO: enable JDito-methods + return translate.text("no valid format"); + return null; + } + break; + case "TELEPHONE": + callbackFn = function (addrValue, ext){ + var country = null; + if (addrValue[0] != "+") //if the number starts with a country-identifier (e.g. +49) no country needs to be specified + country = ext.countryCode; +// if (!cti.isValidPhoneNumber(addrValue, country))//TODO: enable JDito-methods +// return translate.text("no valid phone number"); + return null; + } + break; + default: + callbackFn = null; + break; + } + return callbackFn; +} + +/** + * returns a blueprint for validation extensions; these extensions are needed for validating comm data and can be passed to other functions + * @return {object} a object with properties that have a specific default value; normally you want to overwrite that value + */ +CommValidationUtil.getExtensionsBlueprint = function(){ + return { + countryCode: null + }; +} -- GitLab