feat(backend): Validatie dat targetAges aangegeven zijn voor geüploade leerobjecten.
This commit is contained in:
		
							parent
							
								
									bf1a90313d
								
							
						
					
					
						commit
						5fc7f2f9b4
					
				
					 3 changed files with 6 additions and 2 deletions
				
			
		|  | @ -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); | ||||
|     }, | ||||
|  |  | |||
|  | @ -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, | ||||
|  |  | |||
|  | @ -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 { | ||||
|  |  | |||
		Reference in a new issue
	
	 Gerald Schmittinger
						Gerald Schmittinger