feat: introduce Joi validation schemas and integrate them across various controllers for categories, lessons, courses, chapters, announcements, and admin course approvals.
All checks were successful
Build and Deploy Backend / Build Backend Docker Image (push) Successful in 26s
Build and Deploy Backend / Deploy E-learning Backend to Dev Server (push) Successful in 3s
Build and Deploy Backend / Notify Deployment Status (push) Successful in 2s

This commit is contained in:
JakkrapartXD 2026-02-18 15:59:40 +07:00
parent c5aa195b13
commit b56f604890
14 changed files with 553 additions and 28 deletions

View file

@ -0,0 +1,30 @@
import Joi from 'joi';
/**
* Validator for approving a course
* Comment is optional
*/
export const ApproveCourseValidator = Joi.object({
comment: Joi.string()
.max(1000)
.optional()
.messages({
'string.max': 'Comment must not exceed 1000 characters'
})
});
/**
* Validator for rejecting a course
* Comment is required when rejecting
*/
export const RejectCourseValidator = Joi.object({
comment: Joi.string()
.min(10)
.max(1000)
.required()
.messages({
'string.min': 'Comment must be at least 10 characters when rejecting a course',
'string.max': 'Comment must not exceed 1000 characters',
'any.required': 'Comment is required when rejecting a course'
})
});