30 lines
795 B
TypeScript
30 lines
795 B
TypeScript
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'
|
|
})
|
|
});
|