feat: introduce Joi validation schemas and integrate them across various controllers for categories, lessons, courses, chapters, announcements, and admin course approvals.
This commit is contained in:
parent
c5aa195b13
commit
b56f604890
14 changed files with 553 additions and 28 deletions
|
|
@ -11,6 +11,7 @@ import {
|
|||
YouTubeVideoResponse,
|
||||
SetYouTubeVideoBody,
|
||||
} from '../types/ChaptersLesson.typs';
|
||||
import { SetYouTubeVideoValidator } from '../validators/Lessons.validator';
|
||||
|
||||
const chaptersLessonService = new ChaptersLessonService();
|
||||
|
||||
|
|
@ -213,12 +214,8 @@ export class LessonsController {
|
|||
const token = request.headers.authorization?.replace('Bearer ', '');
|
||||
if (!token) throw new ValidationError('No token provided');
|
||||
|
||||
if (!body.youtube_video_id) {
|
||||
throw new ValidationError('YouTube video ID is required');
|
||||
}
|
||||
if (!body.video_title) {
|
||||
throw new ValidationError('Video title is required');
|
||||
}
|
||||
const { error } = SetYouTubeVideoValidator.validate(body);
|
||||
if (error) throw new ValidationError(error.details[0].message);
|
||||
|
||||
return await chaptersLessonService.setYouTubeVideo({
|
||||
token,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue