import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
import { MAX_MOTIVO_ANULACION_GASTO } from '../motivo-anulacion';

export class AnularGastoDto {
  @ApiProperty({ description: 'Motivo de la anulación (obligatorio)', maxLength: MAX_MOTIVO_ANULACION_GASTO })
  @Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
  @IsString()
  @IsNotEmpty()
  @MaxLength(MAX_MOTIVO_ANULACION_GASTO, {
    message: `El motivo de la anulación no puede superar ${MAX_MOTIVO_ANULACION_GASTO} caracteres`,
  })
  motivo: string;
}
