From b8b5adba83d16bc567b9b35eaafb74e89b4060e2 Mon Sep 17 00:00:00 2001 From: alaskowski <alaskowski@ethz.ch> Date: Tue, 19 Sep 2023 14:02:38 +0200 Subject: [PATCH] SSDM-55: Refactored isDateValid function to avoid 'unknown variable error' --- .../1/as/webapps/eln-lims/html/js/util/Util.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/Util.js b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/Util.js index 33177d9d044..943fba51d17 100644 --- a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/Util.js +++ b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/Util.js @@ -504,22 +504,16 @@ var Util = new function() { } this.isDateValid = function(dateAsString, isDateOnly) { + var result = {isValid : true}; if (dateAsString) { var timeValueObject = Util.parseDate(dateAsString); if(timeValueObject.getFullYear() !== parseInt(dateAsString.substring(0,4))) { - isValid = false; - error = "Incorrect Date Format. Please follow the format " + (isDateOnly ? 'yyyy-MM-dd (YEAR-MONTH-DAY)' : 'yyyy-MM-dd HH:mm:ss (YEAR-MONTH-DAY : HOUR-MINUTE-SECOND)') + "."; - } else { - isValid = true; + result.isValid = false; + result.error = "Incorrect Date Format. Please follow the format " + (isDateOnly ? 'yyyy-MM-dd (YEAR-MONTH-DAY)' : 'yyyy-MM-dd HH:mm:ss (YEAR-MONTH-DAY : HOUR-MINUTE-SECOND)') + "."; } - - return { - isValid : isValid, - error : error - }; } - return { isValid : true} + return result; } this.getFormatedDate = function(date) { -- GitLab