Snai3i-MarketPlace / backend / src / services / course / course.validator.ts
course.validator.ts
Raw
import { body } from 'express-validator';

export const snai3iCourseValidators = [
  body('title').notEmpty().withMessage('Title is required'),
  body('description').notEmpty().withMessage('Description is required'),
  body('chapters').notEmpty().withMessage('Enter at least one chapter'),
  body('status').optional(),
  body('thumbnail').optional(),
];

export const marketCourseValidators = [
  body('title').notEmpty().withMessage('Title is required'),
  body('description').notEmpty().withMessage('Description is required'),
  body('totalHours').notEmpty().withMessage('Total hours is required'),
  body('price').notEmpty().withMessage('Price is required'),
  body('tags').notEmpty().withMessage('Tags are required'),
  body('chaptersCount').notEmpty().withMessage('Chapters count is required'),
  body('thumbnail').optional(),
  body('videoThumbnail').optional(),
  body('status').optional(),
];

// update status
// body status required and in [active , pendingCreation, pendingUpdating, rejected]
export const courseStatusValidator = [
  body('status')
    .notEmpty()
    .withMessage('Status is required')
    .isIn(['active', 'pendingCreation', 'pendingUpdating', 'rejected', 'inactive']),
];