import { ApiProperty } from '@nestjs/swagger';
import { IsIn, IsNotEmpty, IsNumber, IsPositive, Max } from 'class-validator';
import { TransactionTypeEnum } from '../transaction-type.enum';

export class CreateTransactionDto {
  @ApiProperty({ example: 0 })
  @IsNotEmpty()
  playerId: number;

  @ApiProperty({ example: 'Extra teuer wegen diskutierens' })
  note?: string | null;

  @ApiProperty({ example: 'isotimestring' })
  @IsNotEmpty()
  date: string;

  @ApiProperty({ example: 10 })
  @IsNumber({ maxDecimalPlaces: 2 })
  @IsPositive()
  @Max(10000)
  amount: number;

  @ApiProperty({ enum: TransactionTypeEnum })
  @IsIn(Object.values(TransactionTypeEnum).filter((v) => typeof v === 'number'))
  type: TransactionTypeEnum;
}
