mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 10:19:20 +03:00
23 lines
815 B
TypeScript
23 lines
815 B
TypeScript
import { schema, rules } from '@ioc:Adonis/Core/Validator';
|
|
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
|
import CourseStatusEnum from 'App/Datatypes/Enums/CourseStatusEnum';
|
|
|
|
export default class CreateCourseValidator {
|
|
constructor(protected ctx: HttpContextContract) {}
|
|
|
|
public schema = schema.create({
|
|
title: schema.string(),
|
|
description: schema.string(),
|
|
education_description: schema.string.nullable(),
|
|
image: schema.file.optional({
|
|
size: '10mb',
|
|
extnames: ['jpg', 'jpeg', 'png'],
|
|
}),
|
|
teacher_id: schema.string({}, [rules.exists({ table: 'users', column: 'id' })]),
|
|
category_id: schema.string({}, [rules.exists({ table: 'categories', column: 'id' })]),
|
|
status: schema.enum(Object.values(CourseStatusEnum)),
|
|
});
|
|
|
|
public messages = {};
|
|
}
|