Skip to content

Commit

Permalink
remove isValidType check
Browse files Browse the repository at this point in the history
  • Loading branch information
harshaio committed Mar 13, 2024
1 parent 97b22a7 commit 15afc4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
26 changes: 0 additions & 26 deletions src/appmixer/utils/controls/SetVariable/SetVariable.js
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/appmixer/utils/controls/bundle.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -65,6 +65,9 @@
],
"1.8.1": [
"Fix Each component to handle transforms properly."
],
"1.8.2": [
"Fix SetVariable: Handles all types of variables."
]
}
}

0 comments on commit 15afc4e

Please sign in to comment.