mirror of
https://github.com/strapi/strapi.git
synced 2025-11-10 15:19:00 +00:00
set correct path for duplicate create error
This commit is contained in:
parent
3024e94438
commit
d724b1a1f6
@ -15,7 +15,12 @@ const validateCreateFolderSchema = yup
|
|||||||
.min(1)
|
.min(1)
|
||||||
.matches(NO_SLASH_REGEX, 'name cannot contain slashes')
|
.matches(NO_SLASH_REGEX, 'name cannot contain slashes')
|
||||||
.matches(NO_SPACES_AROUND, 'name cannot start or end with a whitespace')
|
.matches(NO_SPACES_AROUND, 'name cannot start or end with a whitespace')
|
||||||
.required(),
|
.required()
|
||||||
|
.test('is-folder-unique', 'name already taken', async function(name) {
|
||||||
|
const { exists } = getService('folder');
|
||||||
|
const doesExist = await exists({ parent: this.parent.parent || null, name });
|
||||||
|
return !doesExist;
|
||||||
|
}),
|
||||||
parent: yup
|
parent: yup
|
||||||
.strapiID()
|
.strapiID()
|
||||||
.nullable()
|
.nullable()
|
||||||
@ -30,12 +35,7 @@ const validateCreateFolderSchema = yup
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.noUnknown()
|
.noUnknown()
|
||||||
.required()
|
.required();
|
||||||
.test('is-folder-unique', 'name already taken', async folder => {
|
|
||||||
const { exists } = getService('folder');
|
|
||||||
const doesExist = await exists({ parent: folder.parent || null, name: folder.name });
|
|
||||||
return !doesExist;
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
validateCreateFolder: validateYupSchema(validateCreateFolderSchema),
|
validateCreateFolder: validateYupSchema(validateCreateFolderSchema),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user