143 lines
6.5 KiB
TypeScript
Executable File
143 lines
6.5 KiB
TypeScript
Executable File
import { ApiProperty } from "@nestjs/swagger";
|
|
import {
|
|
IsBoolean,
|
|
IsDateString,
|
|
IsEnum,
|
|
IsInt,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsString,
|
|
IsUUID,
|
|
IsUrl,
|
|
Length,
|
|
MaxLength,
|
|
} from "class-validator";
|
|
|
|
import { CategoryMessage, ServiceMessage } from "../../../common/enums/message.enum";
|
|
import { ServicesLanguage } from "../enums/services-language.enum";
|
|
|
|
export class CreateServiceDto {
|
|
@IsNotEmpty({ message: CategoryMessage.CAT_ID_NOT_EMPTY })
|
|
@IsUUID("4", { message: CategoryMessage.CAT_ID_SHOULD_BE_UUID })
|
|
@ApiProperty({ description: "The category id of the service", example: "00000000-0000-0000-0000-000000000000" })
|
|
categoryId: string;
|
|
|
|
@IsNotEmpty({ message: ServiceMessage.NAME_REQUIRED })
|
|
@IsString({ message: ServiceMessage.NAME_STRING })
|
|
@Length(3, 150, { message: ServiceMessage.NAME_LENGTH })
|
|
@ApiProperty({ description: "The name of the service", example: "Service Name" })
|
|
name: string;
|
|
|
|
@IsNotEmpty({ message: ServiceMessage.TITLE_REQUIRED })
|
|
@IsString({ message: ServiceMessage.TITLE_STRING })
|
|
@Length(3, 150, { message: ServiceMessage.TITLE_LENGTH })
|
|
@ApiProperty({ description: "The TITLE of the service", example: "Service TITLE" })
|
|
title: string;
|
|
|
|
@IsOptional()
|
|
@IsNotEmpty({ message: ServiceMessage.PAGE_TITLE_REQUIRED })
|
|
@IsString({ message: ServiceMessage.PAGE_TITLE_STRING })
|
|
@Length(3, 500, { message: ServiceMessage.PAGE_TITLE_LENGTH })
|
|
@ApiProperty({ description: "The page title of the service", example: "Service Page Title" })
|
|
pageTitle?: string;
|
|
|
|
@IsOptional()
|
|
@IsNotEmpty({ message: ServiceMessage.PAGE_DESCRIPTION_REQUIRED })
|
|
@IsString({ message: ServiceMessage.PAGE_DESCRIPTION_STRING })
|
|
@Length(10, 500, { message: ServiceMessage.PAGE_DESCRIPTION_LENGTH })
|
|
@ApiProperty({ description: "The page description of the service", example: "Service Page Description" })
|
|
pageDescription?: string;
|
|
|
|
@IsNotEmpty({ message: ServiceMessage.DESCRIPTION_REQUIRED })
|
|
@IsString({ message: ServiceMessage.DESCRIPTION_STRING })
|
|
@Length(10, 500, { message: ServiceMessage.DESCRIPTION_LENGTH })
|
|
@ApiProperty({ description: "The description of the service", example: "Service Description" })
|
|
description: string;
|
|
|
|
@IsNotEmpty({ message: ServiceMessage.AUTHOR_REQUIRED })
|
|
@IsString({ message: ServiceMessage.AUTHOR_STRING })
|
|
@Length(3, 100, { message: ServiceMessage.AUTHOR_LENGTH })
|
|
@ApiProperty({ description: "The author of the service", example: "danak corp" })
|
|
author: string;
|
|
|
|
@IsNotEmpty({ message: ServiceMessage.CREATE_DATE_REQUIRED })
|
|
@IsDateString({}, { message: ServiceMessage.CREATE_DATE_STRING })
|
|
@ApiProperty({ description: "The create date of the service", example: "2021-08-01T00:00:00.000Z" })
|
|
createDate: Date;
|
|
|
|
@IsNotEmpty({ message: ServiceMessage.USER_COUNT_REQUIRED })
|
|
@IsInt({ message: ServiceMessage.USER_COUNT_INT })
|
|
@ApiProperty({ description: "The user count of the service", example: 1000 })
|
|
userCount: number;
|
|
|
|
@IsNotEmpty({ message: ServiceMessage.SERVICE_LANGUAGE_REQUIRED })
|
|
@IsEnum(ServicesLanguage)
|
|
@ApiProperty({ enum: ServicesLanguage, description: "The language of the service", example: ServicesLanguage.ENGLISH })
|
|
serviceLanguage: ServicesLanguage;
|
|
|
|
@IsNotEmpty({ message: ServiceMessage.SOFTWARE_LANGUAGE_REQUIRED })
|
|
@IsString({ message: ServiceMessage.SOFTWARE_LANGUAGE_STRING })
|
|
@MaxLength(150, { message: ServiceMessage.SOFTWARE_LANGUAGE_LENGTH })
|
|
@ApiProperty({ description: "The software language of the service", example: "Python" })
|
|
softwareLanguage: string;
|
|
|
|
@IsNotEmpty({ message: ServiceMessage.META_DESCRIPTION_REQUIRED })
|
|
@IsString({ message: ServiceMessage.META_DESCRIPTION_REQUIRED })
|
|
@ApiProperty({ description: "The meta description of the service", example: "Service Meta Description" })
|
|
metaDescription: string;
|
|
|
|
@IsNotEmpty({ message: ServiceMessage.LINK_REQUIRED })
|
|
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: ServiceMessage.LINK_SHOULD_BE_URL })
|
|
@ApiProperty({ description: "The status of the service", example: "https://example.com" })
|
|
link: string;
|
|
|
|
@IsNotEmpty({ message: ServiceMessage.IS_DANAK_SUGGEST_REQUIRED })
|
|
@IsBoolean({ message: ServiceMessage.IS_DANAK_SUGGEST_BOOLEAN })
|
|
@ApiProperty({ description: "Is the service a Danak suggest?", example: true })
|
|
isDanakSuggest: boolean;
|
|
|
|
@IsOptional()
|
|
@IsNotEmpty({ message: ServiceMessage.SHOW_IN_SLIDER_REQUIRED })
|
|
@IsBoolean({ message: ServiceMessage.SHOW_IN_SLIDER_BOOLEAN })
|
|
@ApiProperty({ description: "Is the service show in slider?", example: true })
|
|
showInSlider?: boolean;
|
|
|
|
@IsNotEmpty({ message: ServiceMessage.ICON_REQUIRED })
|
|
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: ServiceMessage.ICON_SHOULD_BE_URL })
|
|
@ApiProperty({ description: "The icon url of the service", example: "https://example.com/icon.png" })
|
|
icon: string;
|
|
|
|
@IsNotEmpty({ message: ServiceMessage.IMAGES_REQUIRED })
|
|
@IsString({ each: true })
|
|
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: ServiceMessage.IMAGES_SHOULD_BE_URL })
|
|
@ApiProperty({ description: "The images of the service", example: ["https://example.com/image1.png", "https://example.com/image2.png"] })
|
|
images: string[];
|
|
|
|
@IsOptional()
|
|
@IsNotEmpty({ message: ServiceMessage.AUDIOS_REQUIRED })
|
|
@IsString({ each: true })
|
|
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: ServiceMessage.AUDIOS_SHOULD_BE_URL })
|
|
@ApiProperty({ description: "The audios of the service", example: ["https://example.com/audio1.mp3", "https://example.com/audio2.mp3"] })
|
|
audios?: string[];
|
|
|
|
@IsOptional()
|
|
@IsNotEmpty({ message: ServiceMessage.VIDEOS_REQUIRED })
|
|
@IsString({ each: true })
|
|
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: ServiceMessage.VIDEOS_SHOULD_BE_URL })
|
|
@ApiProperty({ description: "The videos of the service", example: ["https://example.com/video1.mp4", "https://example.com/video2.mp4"] })
|
|
videos?: string[];
|
|
|
|
@IsOptional()
|
|
@IsNotEmpty({ message: ServiceMessage.COVER_URL_REQUIRED })
|
|
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: ServiceMessage.COVER_URL_SHOULD_BE_URL })
|
|
@ApiProperty({ description: "The cover url of the service", example: "https://example.com/cover.png" })
|
|
coverUrl?: string;
|
|
|
|
@IsOptional()
|
|
@IsNotEmpty({ message: ServiceMessage.SLUG_REQUIRED })
|
|
@IsString({ message: ServiceMessage.SLUG_STRING })
|
|
@Length(3, 150, { message: ServiceMessage.SLUG_LENGTH })
|
|
@ApiProperty({ description: "The slug of the service", example: "service-slug" })
|
|
slug?: string;
|
|
}
|