Skip to content

Commit d590694

Browse files
[FEATURE] Séparer les schémas d'éléments acceptés dans le stepper par rapport au component element (PIX-15063)
#10431
2 parents 0af5ac3 + f6b3705 commit d590694

File tree

1 file changed

+14
-1
lines changed
  • api/tests/devcomp/unit/infrastructure/datasources/learning-content/validation

1 file changed

+14
-1
lines changed

api/tests/devcomp/unit/infrastructure/datasources/learning-content/validation/module-schema.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ const elementSchema = Joi.alternatives().conditional('.type', {
4141
],
4242
});
4343

44+
const stepperElementSchema = Joi.alternatives().conditional('.type', {
45+
switch: [
46+
{ is: 'download', then: downloadElementSchema },
47+
{ is: 'image', then: imageElementSchema },
48+
{ is: 'qcu', then: qcuElementSchema },
49+
{ is: 'qcm', then: qcmElementSchema },
50+
{ is: 'qrocm', then: qrocmElementSchema },
51+
{ is: 'separator', then: separatorElementSchema },
52+
{ is: 'text', then: textElementSchema },
53+
{ is: 'video', then: videoElementSchema },
54+
],
55+
});
56+
4457
const componentElementSchema = Joi.object({
4558
type: Joi.string().valid('element').required(),
4659
element: elementSchema.required(),
@@ -51,7 +64,7 @@ const componentStepperSchema = Joi.object({
5164
steps: Joi.array()
5265
.items(
5366
Joi.object({
54-
elements: Joi.array().items(elementSchema).required(),
67+
elements: Joi.array().items(stepperElementSchema).required(),
5568
}),
5669
)
5770
.min(2)

0 commit comments

Comments
 (0)