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; }