Files
dsc-api/src/modules/danak-services/DTO/create-service.dto.ts
T
2025-02-26 20:15:16 +03:30

83 lines
4.1 KiB
TypeScript
Executable File

import { ApiProperty } from "@nestjs/swagger";
import { IsBoolean, IsDateString, IsEnum, IsInt, IsNotEmpty, 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;
@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;
@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 })
@ApiProperty({ description: "The images of the service", example: ["https://example.com/image1.png", "https://example.com/image2.png"] })
images: string[];
}