import { ApiProperty } from '@nestjs/swagger';
import { Transform, type TransformFnParams } from 'class-transformer';
import { IsInt, IsNotEmpty, IsString, MaxLength, Min } from 'class-validator';
import { Type } from 'class-transformer';

function trimString({ value }: TransformFnParams): unknown {
  return typeof value === 'string' ? value.trim() : value;
}

export class SaveMeetingSummaryIssueCommentDto {
  @ApiProperty({ description: 'Comment type id, from GET /comment-types.' })
  @Type(() => Number)
  @IsInt()
  @Min(1)
  commentTypeId!: number;

  @ApiProperty({
    description: 'The comment text.',
    maxLength: 10000,
  })
  @Transform(trimString)
  @IsString()
  @IsNotEmpty()
  @MaxLength(10000)
  comment!: string;
}
