From 300c0b721d7bfbb904c95c7aa5b0248560f14821 Mon Sep 17 00:00:00 2001 From: Gerald Schmittinger Date: Wed, 14 May 2025 22:45:01 +0200 Subject: [PATCH] feat(backend): Validatie bestemming overgangen --- .../src/services/learning-paths/learning-path-service.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/src/services/learning-paths/learning-path-service.ts b/backend/src/services/learning-paths/learning-path-service.ts index 5645f95a..5f7a5032 100644 --- a/backend/src/services/learning-paths/learning-path-service.ts +++ b/backend/src/services/learning-paths/learning-path-service.ts @@ -13,6 +13,7 @@ import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher'; import { mapToTeacher } from '../../interfaces/teacher.js'; import { Collection } from '@mikro-orm/core'; import { NotFoundException } from '../../exceptions/not-found-exception.js'; +import { BadRequestException } from '../../exceptions/bad-request-exception.js'; const userContentPrefix = getEnvVar(envVars.UserContentPrefix); const allProviders = [dwengoApiLearningPathProvider, databaseLearningPathProvider]; @@ -61,10 +62,8 @@ export function mapToLearningPath(dto: LearningPath, adminsDto: TeacherDTO[]): L condition: transDto.condition ?? 'true', }); } - return undefined; - }) - .filter((it) => it) - .map((it) => it!); + throw new BadRequestException(`Invalid transition destination: ${JSON.stringify(transDto.next)}: This learning object does not exist in this learning path.`); + }); fromNode.transitions = new Collection(fromNode, transitions); });