From 09d6bc8169df0e641602e0b153de0458a1fb1ec5 Mon Sep 17 00:00:00 2001 From: Dipin Jagadish Date: Wed, 1 Nov 2023 18:36:39 +0000 Subject: [PATCH] fix: address validation issue in schema --- .../components/Sidebar/NewRequest/index.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/bruno-app/src/components/Sidebar/NewRequest/index.js b/packages/bruno-app/src/components/Sidebar/NewRequest/index.js index f6bcdfeb..43d91430 100644 --- a/packages/bruno-app/src/components/Sidebar/NewRequest/index.js +++ b/packages/bruno-app/src/components/Sidebar/NewRequest/index.js @@ -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) {