feat(backend): Validatie dat targetAges aangegeven zijn voor geüploade leerobjecten.

This commit is contained in:
Gerald Schmittinger 2025-05-16 12:49:10 +02:00
parent bf1a90313d
commit 5fc7f2f9b4
3 changed files with 6 additions and 2 deletions

View file

@ -103,7 +103,7 @@ const learningObjectService = {
const learningObjectRepo = getLearningObjectRepository();
const learningObject = await learningObjectRepo.findByIdentifier(id);
if (!learningObject) {
throw new NotFoundException('The specified learning object does not exist.');
throw new NotFoundException('learningObjectNotFound');
}
return learningObject.admins.map((admin) => admin.username);
},

View file

@ -68,6 +68,10 @@ function createLearningObject(metadata: LearningObjectMetadata, content: Buffer,
callbackSchema: metadata.return_value?.callback_schema ? JSON.stringify(metadata.return_value.callback_schema) : '',
};
if (!metadata.target_ages || metadata.target_ages.length === 0) {
throw new BadRequestException("errorTargetAgesMandatory");
}
const learningObject = learningObjectRepo.create({
admins: [],
available: metadata.available ?? true,

View file

@ -150,7 +150,7 @@ const learningPathService = {
)
);
if (learningObjectsOnPath.some(it => !it)) {
throw new BadRequestException("At least one of the specified learning objects does not exist.")
throw new BadRequestException("pathContainsNonExistingLearningObjects")
}
try {