mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-26 00:29:11 +01:00
Merge pull request #512 from therealrinku/three
fix: add request and folder modal validation fixes
This commit is contained in:
commit
9c3c28be42
@ -16,6 +16,7 @@ const NewFolder = ({ collection, item, onClose }) => {
|
|||||||
},
|
},
|
||||||
validationSchema: Yup.object({
|
validationSchema: Yup.object({
|
||||||
folderName: Yup.string()
|
folderName: Yup.string()
|
||||||
|
.trim()
|
||||||
.min(1, 'must be at least 1 character')
|
.min(1, 'must be at least 1 character')
|
||||||
.required('name is required')
|
.required('name is required')
|
||||||
.test({
|
.test({
|
||||||
@ -32,7 +33,7 @@ const NewFolder = ({ collection, item, onClose }) => {
|
|||||||
onSubmit: (values) => {
|
onSubmit: (values) => {
|
||||||
dispatch(newFolder(values.folderName, collection.uid, item ? item.uid : null))
|
dispatch(newFolder(values.folderName, collection.uid, item ? item.uid : null))
|
||||||
.then(() => onClose())
|
.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'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -25,13 +25,14 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => {
|
|||||||
},
|
},
|
||||||
validationSchema: Yup.object({
|
validationSchema: Yup.object({
|
||||||
requestName: Yup.string()
|
requestName: Yup.string()
|
||||||
|
.trim()
|
||||||
.min(1, 'must be at least 1 character')
|
.min(1, 'must be at least 1 character')
|
||||||
.required('name is required')
|
.required('name is required')
|
||||||
.test({
|
.test({
|
||||||
name: 'requestName',
|
name: 'requestName',
|
||||||
message: `The request names - collection and folder is reserved in bruno`,
|
message: `The request names - collection and folder is reserved in bruno`,
|
||||||
test: (value) => {
|
test: (value) => {
|
||||||
const trimmedValue = value.trim().toLowerCase();
|
const trimmedValue = value ? value.trim().toLowerCase() : '';
|
||||||
return !['collection', 'folder'].includes(trimmedValue);
|
return !['collection', 'folder'].includes(trimmedValue);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user