fix: input form value type error (#3399)

This commit is contained in:
Archer
2024-12-15 19:58:50 +08:00
committed by GitHub
parent 3deac290bf
commit c995bccef8
3 changed files with 10 additions and 6 deletions

View File

@@ -284,9 +284,13 @@ export const formatVariableValByType = (val: any, valueType?: WorkflowIOValueTyp
if (!valueType) return val;
// Value type check, If valueType invalid, return undefined
if (valueType.startsWith('array') && !Array.isArray(val)) return undefined;
if (valueType === WorkflowIOValueTypeEnum.boolean && typeof val !== 'boolean') return undefined;
if (valueType === WorkflowIOValueTypeEnum.number && typeof val !== 'number') return undefined;
if (valueType === WorkflowIOValueTypeEnum.string && typeof val !== 'string') return undefined;
if (valueType === WorkflowIOValueTypeEnum.boolean) return Boolean(val);
if (valueType === WorkflowIOValueTypeEnum.number) return Number(val);
if (valueType === WorkflowIOValueTypeEnum.string) {
if (val === undefined) return 'undefined';
if (val === null) return 'null';
return typeof val === 'object' ? JSON.stringify(val) : String(val);
}
if (
[
WorkflowIOValueTypeEnum.object,