From 62ff6026dc6c0425947f1012fc95e47db948b692 Mon Sep 17 00:00:00 2001 From: Arush Date: Wed, 19 Jun 2024 14:58:33 +0530 Subject: [PATCH] fix: fixed handling of empty string in requiredString and warningString --- src/Utilities/Utils.res | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res index 8336197e7..bfe17b988 100644 --- a/src/Utilities/Utils.res +++ b/src/Utilities/Utils.res @@ -110,14 +110,12 @@ let getDecodedBoolFromJson = (json, callbackFunc, defaultValue) => { let getRequiredString = (dict, key, default, ~logger) => { let optionalStr = getOptionString(dict, key) switch optionalStr { - | Some(val) => { - val == "" ? manageErrorWarning(REQUIRED_PARAMETER, ~dynamicStr=key, ~logger, ()) : () - val - } - | None => { + | None + | Some("") => { manageErrorWarning(REQUIRED_PARAMETER, ~dynamicStr=key, ~logger, ()) optionalStr->Option.getOr(default) } + | Some(val) => val } } @@ -125,10 +123,11 @@ let getWarningString = (dict, key, default, ~logger) => { switch dict->Dict.get(key) { | Some(val) => switch val->JSON.Decode.string { - | Some(val) => val - | None => + | None + | Some("") => manageErrorWarning(TYPE_STRING_ERROR, ~dynamicStr=key, ~logger, ()) default + | Some(val) => val } | None => default }