mirror of
https://github.com/strapi/strapi.git
synced 2025-12-05 03:21:22 +00:00
feat: validation to update workflow
This commit is contained in:
parent
ab40c6a80b
commit
8fceb4cc4d
@ -8,12 +8,6 @@ const stageObject = yup.object().shape({
|
||||
color: yup.string().matches(/^#(?:[0-9a-fA-F]{3}){1,2}$/i), // hex color
|
||||
});
|
||||
|
||||
const validateUpdateStagesSchema = yup
|
||||
.array()
|
||||
.of(stageObject)
|
||||
.required()
|
||||
.max(200, 'You can not create more than 200 stages');
|
||||
|
||||
const validateUpdateStageOnEntity = yup
|
||||
.object()
|
||||
.shape({
|
||||
@ -23,20 +17,25 @@ const validateUpdateStageOnEntity = yup
|
||||
|
||||
const validateWorkflowCreateSchema = yup.object().shape({
|
||||
name: yup.string().max(255).required(),
|
||||
stages: yup.array().of(stageObject).min(1, 'Can not create a workflow without stages').required(),
|
||||
stages: yup
|
||||
.array()
|
||||
.of(stageObject)
|
||||
.min(1, 'Can not create a workflow without stages')
|
||||
.max(200, 'Can not have more than 200 stages')
|
||||
.required(),
|
||||
});
|
||||
|
||||
const validateWorkflowUpdateSchema = yup.object().shape({
|
||||
name: yup.string().max(255),
|
||||
stages: yup.array().of(stageObject),
|
||||
stages: yup
|
||||
.array()
|
||||
.of(stageObject)
|
||||
.min(1, 'Can not create a workflow without stages')
|
||||
.max(200, 'Can not have more than 200 stages'),
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
validateWorkflowCreate: validateYupSchema(validateWorkflowCreateSchema),
|
||||
validateUpdateStages: validateYupSchema(validateUpdateStagesSchema, {
|
||||
strict: false,
|
||||
stripUnknown: true,
|
||||
}),
|
||||
validateUpdateStageOnEntity: validateYupSchema(validateUpdateStageOnEntity),
|
||||
validateWorkflowUpdate: validateYupSchema(validateWorkflowUpdateSchema),
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user