From 15afc4e5fdc197c5ec367d1bcd7c8ffb5cace219 Mon Sep 17 00:00:00 2001 From: harshaio Date: Wed, 13 Mar 2024 16:13:01 +0530 Subject: [PATCH] remove isValidType check --- .../utils/controls/SetVariable/SetVariable.js | 26 ------------------- src/appmixer/utils/controls/bundle.json | 5 +++- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/appmixer/utils/controls/SetVariable/SetVariable.js b/src/appmixer/utils/controls/SetVariable/SetVariable.js index 7c8f68677..8235b0e15 100644 --- a/src/appmixer/utils/controls/SetVariable/SetVariable.js +++ b/src/appmixer/utils/controls/SetVariable/SetVariable.js @@ -1,28 +1,5 @@ 'use strict'; -const isValidType = (value, expectedType) => { - switch (expectedType) { - case 'number': - // Check for both type 'number' and not NaN - return typeof value === 'number' && !isNaN(value); - case 'text': - case 'textarea': - case 'filepicker': - // Check for type 'string' - return typeof value === 'string'; - case 'date-time': - // Check for a valid date; Date.parse returns NaN for invalid dates - return typeof value === 'string' && !isNaN(Date.parse(value)); - case 'toggle': - // Check for boolean type - return typeof value === 'boolean'; - default: - // Unexpected type, could log this or handle as needed - return false; - } -}; - - /** * OnStart component reacts to the 'start' message only. It triggers when the flow starts. * @extends {Component} @@ -49,9 +26,6 @@ module.exports = { // type can be number, text, textarea, filepicker, date and toggle const { name, type, ...value } = variable; - if (!isValidType(value[type], type)) { - throw new context.CancelError(`Type mismatch for variable "${name}". Expected type: ${type}.`); - } outputObject[name] = value[type]; }); // Send the output diff --git a/src/appmixer/utils/controls/bundle.json b/src/appmixer/utils/controls/bundle.json index 46cd8e685..5808eff71 100644 --- a/src/appmixer/utils/controls/bundle.json +++ b/src/appmixer/utils/controls/bundle.json @@ -1,7 +1,7 @@ { "name": "appmixer.utils.controls", "engine": ">=5.1.1", - "version": "1.8.1", + "version": "1.8.2", "changelog": { "1.0.0": [ "Initial version" @@ -65,6 +65,9 @@ ], "1.8.1": [ "Fix Each component to handle transforms properly." + ], + "1.8.2": [ + "Fix SetVariable: Handles all types of variables." ] } }