// SPDX-License-Identifier: AGPL-3.0
import * as React from 'react';
+import { memoize } from 'lodash/fp';
import { FloatCommandInputParameter, isRequiredInput } from '~/models/workflow';
import { Field } from 'redux-form';
import { isNumber } from '~/validators/is-number';
component={Input}
parse={parseFloat}
format={format}
- validate={[
- isRequiredInput(input)
- ? isNumber
- : () => undefined,]} />;
+ validate={getValidation(input)} />;
const format = (value: any) => isNaN(value) ? '' : JSON.stringify(value);
+const getValidation = memoize(
+ (input: FloatCommandInputParameter) => ([
+ isRequiredInput(input)
+ ? isNumber
+ : () => undefined,])
+);
+
const Input = (props: GenericInputProps) =>
<GenericInput
component={InputComponent}