mirror of
https://github.com/strapi/strapi.git
synced 2025-11-05 04:13:36 +00:00
feat: validate workflow assignedCT update
This commit is contained in:
parent
1f90e94d78
commit
1b1cb9f899
@ -15,6 +15,14 @@ const validateUpdateStageOnEntity = yup
|
|||||||
})
|
})
|
||||||
.required();
|
.required();
|
||||||
|
|
||||||
|
const validateAssignedContentTypes = yup.array().of(
|
||||||
|
yup.string().test({
|
||||||
|
name: 'content-type-exists',
|
||||||
|
message: (value) => `Content type ${value.originalValue} does not exist`,
|
||||||
|
test: (uid) => strapi.getModel(uid),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
const validateWorkflowCreateSchema = yup.object().shape({
|
const validateWorkflowCreateSchema = yup.object().shape({
|
||||||
name: yup.string().max(255).required(),
|
name: yup.string().max(255).required(),
|
||||||
stages: yup
|
stages: yup
|
||||||
@ -23,6 +31,7 @@ const validateWorkflowCreateSchema = yup.object().shape({
|
|||||||
.min(1, 'Can not create a workflow without stages')
|
.min(1, 'Can not create a workflow without stages')
|
||||||
.max(200, 'Can not have more than 200 stages')
|
.max(200, 'Can not have more than 200 stages')
|
||||||
.required(),
|
.required(),
|
||||||
|
assignedContentTypes: validateAssignedContentTypes,
|
||||||
});
|
});
|
||||||
|
|
||||||
const validateWorkflowUpdateSchema = yup.object().shape({
|
const validateWorkflowUpdateSchema = yup.object().shape({
|
||||||
@ -30,8 +39,9 @@ const validateWorkflowUpdateSchema = yup.object().shape({
|
|||||||
stages: yup
|
stages: yup
|
||||||
.array()
|
.array()
|
||||||
.of(stageObject)
|
.of(stageObject)
|
||||||
.min(1, 'Can not create a workflow without stages')
|
.min(1, 'Can not update a workflow without stages')
|
||||||
.max(200, 'Can not have more than 200 stages'),
|
.max(200, 'Can not have more than 200 stages'),
|
||||||
|
assignedContentTypes: validateAssignedContentTypes,
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user