import { ApiPropertyOptional } from '@nestjs/swagger';
import { Transform, type TransformFnParams } from 'class-transformer';
import { IsOptional, IsString, MaxLength } from 'class-validator';

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

export class SendBackMeetingSummaryDto {
  @ApiPropertyOptional({
    description:
      'Optional note. The per-issue comments carry the feedback, so this is ' +
      'only for anything that does not belong on a specific issue.',
    required: false,
    maxLength: 2000,
  })
  @IsOptional()
  @Transform(trimString)
  @IsString()
  @MaxLength(2000)
  reason?: string;
}
