From 0a2835a543ced59ab4ffb8b811362c3e2b29bbc8 Mon Sep 17 00:00:00 2001 From: therealrinku Date: Tue, 10 Oct 2023 19:21:21 +0545 Subject: [PATCH] fix: add request and folder modal validation fixes --- packages/bruno-app/src/components/Sidebar/NewFolder/index.js | 3 ++- packages/bruno-app/src/components/Sidebar/NewRequest/index.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/src/components/Sidebar/NewFolder/index.js b/packages/bruno-app/src/components/Sidebar/NewFolder/index.js index bc13f50d..934a3bd2 100644 --- a/packages/bruno-app/src/components/Sidebar/NewFolder/index.js +++ b/packages/bruno-app/src/components/Sidebar/NewFolder/index.js @@ -16,6 +16,7 @@ const NewFolder = ({ collection, item, onClose }) => { }, validationSchema: Yup.object({ folderName: Yup.string() + .trim() .min(1, 'must be at least 1 character') .required('name is required') .test({ @@ -32,7 +33,7 @@ const NewFolder = ({ collection, item, onClose }) => { onSubmit: (values) => { dispatch(newFolder(values.folderName, collection.uid, item ? item.uid : null)) .then(() => onClose()) - .catch((err) => toast.error(err ? err.message : 'An error occurred while adding the request')); + .catch((err) => toast.error(err ? err.message : 'An error occurred while adding the folder')); } }); diff --git a/packages/bruno-app/src/components/Sidebar/NewRequest/index.js b/packages/bruno-app/src/components/Sidebar/NewRequest/index.js index 8a9604b8..2e54b56a 100644 --- a/packages/bruno-app/src/components/Sidebar/NewRequest/index.js +++ b/packages/bruno-app/src/components/Sidebar/NewRequest/index.js @@ -25,13 +25,14 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => { }, validationSchema: Yup.object({ requestName: Yup.string() + .trim() .min(1, 'must be at least 1 character') .required('name is required') .test({ name: 'requestName', message: `The request names - collection and folder is reserved in bruno`, test: (value) => { - const trimmedValue = value.trim().toLowerCase(); + const trimmedValue = value ? value.trim().toLowerCase() : ''; return !['collection', 'folder'].includes(trimmedValue); } })