import { Type } from 'class-transformer';
import { ArrayNotEmpty, IsArray, IsIn, IsInt, IsNumber, IsOptional, IsString, Matches, MaxLength, NotEquals } from 'class-validator';

export class ChangeWalletBalanceDto {
  @IsOptional()
  @IsString()
  @Matches(/^[\w-]{8,64}$/)
  operationId?: string;

  @IsInt()
  studentId: number;

  @IsNumber({ maxDecimalPlaces: 2 })
  @NotEquals(0)
  amount: number;

  @IsIn(['recharge', 'adjustment'])
  type: 'recharge' | 'adjustment';

  @IsOptional()
  @IsString()
  @MaxLength(300)
  description?: string;
}


export class BatchChangeWalletBalanceDto {
  @IsOptional()
  @IsString()
  @Matches(/^[\w-]{8,64}$/)
  operationId?: string;

  @IsArray()
  @ArrayNotEmpty()
  @IsInt({ each: true })
  @Type(() => Number)
  studentIds: number[];

  @IsNumber({ maxDecimalPlaces: 2 })
  @NotEquals(0)
  amount: number;

  @IsIn(['recharge', 'adjustment'])
  type: 'recharge' | 'adjustment';

  @IsOptional()
  @IsString()
  @MaxLength(300)
  description?: string;
}
