Merge pull request #857 from snippetkid/855-fix-yup-schema-validation

Address validation issue in Yup schema
This commit is contained in:
Anoop M D 2023-11-02 13:39:29 +05:30 committed by GitHub
commit b633fc58d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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