File tree Expand file tree Collapse file tree 2 files changed +19
-13
lines changed
components/runCards/JobCard Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,17 @@ import { FileSelector } from "../../FileSelector";
9
9
import type { InputData } from "./JobModal" ;
10
10
import { MultipleMoleculeInput } from "./MultipleMoleculeInput" ;
11
11
12
+ export const validateInputData = ( inputValue : string | string [ ] | undefined ) => {
13
+ if ( inputValue === undefined ) {
14
+ return false ; // when does this happen?
15
+ }
16
+ if ( Array . isArray ( inputValue ) ) {
17
+ return inputValue . every ( ( v ) => v !== "" ) ;
18
+ }
19
+
20
+ return inputValue . split ( "\n" ) . every ( ( v ) => v !== "" ) ;
21
+ } ;
22
+
12
23
// Define types for the form schema as the Open API spec doesn't define these (just gives string)
13
24
// These might be defined in the form generator types?
14
25
export interface InputFieldSchema {
@@ -67,7 +78,9 @@ export const JobInputFields = ({
67
78
const value = inputsData [ key ] || removeFileProtocolFromInputData ( initialValues ?. [ key ] ) ;
68
79
return (
69
80
< InputSection
70
- error = { required && ! value ? "must have required input" : undefined }
81
+ error = {
82
+ required && ! validateInputData ( value ) ? "must have required input" : undefined
83
+ }
71
84
key = { key }
72
85
required = { required }
73
86
title = { title }
@@ -93,7 +106,9 @@ export const JobInputFields = ({
93
106
94
107
return (
95
108
< InputSection
96
- error = { required && ! value ? "must have required input" : undefined }
109
+ error = {
110
+ required && ! validateInputData ( value ) ? "must have required input" : undefined
111
+ }
97
112
key = { key }
98
113
required = { required }
99
114
title = { title }
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ import { ModalWrapper } from "../../modals/ModalWrapper";
21
21
import type { DebugValue } from "../DebugCheckbox" ;
22
22
import { DebugCheckbox } from "../DebugCheckbox" ;
23
23
import type { CommonModalProps } from "../types" ;
24
- import type { InputSchema , JobInputFieldsProps } from "./JobInputFields" ;
24
+ import { type InputSchema , type JobInputFieldsProps , validateInputData } from "./JobInputFields" ;
25
25
26
26
const JobInputFields = dynamic < JobInputFieldsProps > (
27
27
( ) => import ( "./JobInputFields" ) . then ( ( mod ) => mod . JobInputFields ) ,
@@ -51,16 +51,7 @@ export interface JobModalProps extends CommonModalProps {
51
51
52
52
const validateJobInputs = ( required : string [ ] , inputsData : InputData ) => {
53
53
const inputsDataIsValid = Object . values ( inputsData )
54
- . map ( ( inputValue ) => {
55
- if ( inputValue === undefined ) {
56
- return false ; // when does this happen?
57
- }
58
- if ( Array . isArray ( inputValue ) ) {
59
- return inputValue . every ( ( v ) => v !== "" ) ;
60
- }
61
-
62
- return inputValue . split ( "\n" ) . every ( ( v ) => v !== "" ) ;
63
- } )
54
+ . map ( validateInputData )
64
55
. every ( ( v ) => v ) ;
65
56
66
57
const inputKeys = new Set ( Object . keys ( inputsData ) ) ;
You can’t perform that action at this time.
0 commit comments