20493: isArrayOfType handles union type (optional) arrays 20493-optional-array
authorPeter Amstutz <peter.amstutz@curii.com>
Thu, 11 May 2023 18:23:52 +0000 (14:23 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Thu, 11 May 2023 18:23:52 +0000 (14:23 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

src/models/workflow.ts

index e85dce7a6a02e697fe9b674630b530b9599d09cc..59b81a1dfaf3eb8b4070bf1109beb63f313b0a55 100644 (file)
@@ -185,10 +185,13 @@ export const isPrimitiveOfType = (input: GenericCommandInputParameter<any, any>,
         : input.type === type;
 
 export const isArrayOfType = (input: GenericCommandInputParameter<any, any>, type: CWLType) =>
-    typeof input.type === 'object' &&
-        input.type.type === 'array'
-        ? input.type.items === type
-        : false;
+    input.type instanceof Array
+        ? (input.type.filter(t => typeof t === 'object' &&
+            t.type === 'array' &&
+            t.items === type).length > 0)
+        : (typeof input.type === 'object' &&
+            input.type.type === 'array' &&
+            input.type.items === type);
 
 export const stringifyInputType = ({ type }: CommandInputParameter) => {
     if (typeof type === 'string') {