feat: error messages for reserved file and folder names in bruno

This commit is contained in:
Anoop M D 2023-02-07 19:36:34 +05:30
parent 5f59a16090
commit 78ca6c5e96
2 changed files with 21 additions and 2 deletions

View File

@ -15,7 +15,19 @@ const NewFolder = ({ collection, item, onClose }) => {
folderName: ''
},
validationSchema: Yup.object({
folderName: Yup.string().min(1, 'must be atleast 1 characters').max(50, 'must be 50 characters or less').required('name is required')
folderName: Yup.string()
.min(1, 'must be atleast 1 characters')
.required('name is required')
.test({
name: 'folderName',
message: 'The folder name "environments" at the root of the collection is reserved in bruno',
test:(value) => {
if(item && item.uid) {
return true;
}
return !(value.trim().toLowerCase().includes('environments'))
}
})
}),
onSubmit: (values) => {
dispatch(newFolder(values.folderName, collection.uid, item ? item.uid : null))

View File

@ -24,7 +24,14 @@ const NewRequest = ({ collection, item, isEphermal, onClose }) => {
requestMethod: 'GET'
},
validationSchema: Yup.object({
requestName: Yup.string().min(1, 'must be atleast 1 characters').max(50, 'must be 50 characters or less').required('name is required')
requestName: Yup.string()
.min(1, 'must be atleast 1 characters')
.required('name is required')
.test({
name: 'requestName',
message: 'The request name "index" is reserved in bruno',
test: value => !(value.trim().toLowerCase().includes('index')),
})
}),
onSubmit: (values) => {
if (isEphermal) {