Files
backend/src/comments/dto/comment.dto.ts
T
Ali Reza bb59d5e9ba Initial commit: Meshkee CMS API
NestJS backend with Prisma, Docker Compose for Postgres/Redis, and deploy docs for the production VM.
2026-07-21 17:52:36 +03:30

80 lines
1.4 KiB
TypeScript

import { MediaEntityType } from '@prisma/client';
import { Transform, Type } from 'class-transformer';
import {
IsBoolean,
IsEmail,
IsEnum,
IsInt,
IsOptional,
IsString,
Min,
MinLength,
} from 'class-validator';
export class CreatePublicCommentDto {
@IsEnum(MediaEntityType)
entityType!: MediaEntityType;
@IsString()
@MinLength(1)
entityId!: string;
@IsString()
@MinLength(2)
authorName!: string;
@IsOptional()
@IsEmail()
authorEmail?: string;
@IsString()
@MinLength(1)
text!: string;
}
export class ListPublicCommentsDto {
@IsEnum(MediaEntityType)
entityType!: MediaEntityType;
@IsString()
@MinLength(1)
entityId!: string;
}
export class ListCommentsDto {
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
page?: number;
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
pageSize?: number;
@IsOptional()
@IsEnum(MediaEntityType)
entityType?: MediaEntityType;
@IsOptional()
@IsString()
entityId?: string;
/** Filter by approval: true = approved, false = pending, omit = all */
@IsOptional()
@Transform(({ value }) => {
if (value === 'true' || value === true) return true;
if (value === 'false' || value === false) return false;
return value;
})
@IsBoolean()
isApproved?: boolean;
}
export class UpdateCommentApprovalDto {
@IsBoolean()
isApproved!: boolean;
}