Add conditional validation detection to int and float inputs
[arvados-workbench2.git] / src / views / run-process-panel / inputs / int-input.tsx
index 5b6f95dbcbc8f1b176edbfc68eee51ef5ded9074..60a49b61f5295dfb678d9dba28aee79f5206e56f 100644 (file)
@@ -3,7 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { IntCommandInputParameter, getInputLabel } from '~/models/workflow';
+import { IntCommandInputParameter, getInputLabel, isRequiredInput } from '~/models/workflow';
 import { Field } from 'redux-form';
 import { TextField } from '~/components/text-field/text-field';
 import { isInteger } from '~/validators/is-integer';
@@ -18,5 +18,9 @@ export const IntInput = ({ input }: IntInputProps) =>
         component={TextField}
         parse={value => parseInt(value, 10)}
         format={value => isNaN(value) ? '' : JSON.stringify(value)}
-        validate={[isInteger]} />;
+        validate={[
+            isRequiredInput(input)
+                ? isInteger
+                : () => undefined,
+        ]} />;