Files
shop-api/src/modules/product/DTO/createQuestion.dto.ts
T
mahyargdz be82059172 first
2025-09-14 15:15:03 +03:30

90 lines
2.2 KiB
TypeScript

import { Expose, Type } from "class-transformer";
import { IsArray, IsNotEmpty, IsNumber, IsOptional, IsString, Length, ValidateNested } from "class-validator";
import { ApiProperty } from "../../../common/decorator/swggerDocs";
export class CreateQuestionDTO {
@Expose()
@IsNotEmpty()
@IsString()
@Length(8)
@ApiProperty({ type: "string", description: "content of question", example: "جنسش جیه؟" })
content: string;
}
class AnswerContentDTO {
@Expose()
@IsNotEmpty()
@IsString()
@ApiProperty({
type: "string",
description: "Content of the answer",
example: "جنس این محصول چرم است",
})
content: string;
}
export class AnswerQuestionDTO {
@Expose()
@IsArray()
@IsOptional()
@ValidateNested({ each: true })
@Type(() => AnswerContentDTO)
@ApiProperty({
type: "Array",
description: "List of answers",
example: [{ content: "جنس این محصول چرم است" }],
required: false, // Optional field
})
answers?: AnswerContentDTO[];
}
export class CreateAnswerQuestionDTO {
@Expose()
@IsNotEmpty()
@IsString()
@ApiProperty({
type: "string",
description: "Content of the answer",
example: "جنس این محصول چرم است",
})
content: string;
}
export class CreateCommentDTO {
@Expose()
@IsNotEmpty()
@IsString()
@ApiProperty({ type: "string", description: "the title of review", example: "عالی" })
title: string;
@Expose()
@IsOptional()
@IsNotEmpty()
@IsArray()
@IsString({ each: true })
@ApiProperty({ type: "Array", description: "advantage", example: ["عالی", "پر سرعت", "ارزان"] })
advantage: string[];
@Expose()
@IsOptional()
@IsNotEmpty()
@IsArray()
@IsString({ each: true })
@ApiProperty({ type: "Array", description: "disAdvantage", example: ["بد", "کند", "گران"] })
disAdvantage: string[];
@Expose()
@IsNotEmpty()
@IsString()
@Length(8)
@ApiProperty({ type: "string", description: "content of comment", example: "عالی بود" })
content: string;
@Expose()
@IsNotEmpty()
@IsNumber()
@ApiProperty({ type: "number", description: "rate of product", example: 5 })
rate: number;
}