fix: address validation issue in schema

This commit is contained in:
Dipin Jagadish 2023-11-01 18:36:39 +00:00
parent 9cf8a584a0
commit 09d6bc8169

View File

@ -38,14 +38,17 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => {
return !['collection', 'folder'].includes(trimmedValue); return !['collection', 'folder'].includes(trimmedValue);
} }
}), }),
curlCommand: Yup.string() curlCommand: Yup.string().when('requestType', {
.min(1, 'must be at least 1 character') is: (requestType) => requestType === 'from-curl',
.required('curlCommand is required') then: Yup.string()
.test({ .min(1, 'must be at least 1 character')
name: 'curlCommand', .required('curlCommand is required')
message: `Invalid cURL Command`, .test({
test: (value) => getRequestFromCurlCommand(value) !== null name: 'curlCommand',
}) message: `Invalid cURL Command`,
test: (value) => getRequestFromCurlCommand(value) !== null
})
})
}), }),
onSubmit: (values) => { onSubmit: (values) => {
if (isEphemeral) { if (isEphemeral) {