import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Transform, Type } from 'class-transformer'; import { IsDate, IsInt, IsNotEmpty, IsOptional, IsString } from 'class-validator'; export class CreateCategoryDto { @ApiProperty() @IsNotEmpty() @IsString() name!: string; @ApiPropertyOptional() @IsOptional() @IsString() description?: string | null; @ApiPropertyOptional() @IsOptional() @IsInt() @Transform(({ value }) => parseInt(value, 10)) parentId?: number | null; @ApiPropertyOptional() @IsOptional() @IsDate() @Type(() => Date) createdAt?: Date; }