import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsNumber, IsString, IsEnum, Min, Matches, IsOptional, Length } from 'class-validator';
import { ChainType } from '@/domain/value-objects';

export class RequestWithdrawalDTO {
  @ApiProperty({ description: '提现金额 (USDT)', example: 100 })
  @IsNumber()
  @Min(10, { message: '最小提现金额为 10 USDT' })
  amount: number;

  @ApiProperty({
    description: '提现目标地址 (EVM地址或充值ID)',
    example: '0x1234567890abcdef1234567890abcdef12345678',
  })
  @IsString()
  @Matches(/^(0x[a-fA-F0-9]{40}|D\d{11})$/, {
    message: '无效的地址格式，请输入EVM地址(0x...)或充值ID(D...)',
  })
  toAddress: string;

  @ApiProperty({
    description: '目标链类型',
    enum: ChainType,
    example: 'KAVA',
  })
  @IsEnum(ChainType)
  chainType: ChainType;

  @ApiProperty({
    description: '短信验证码',
    example: '123456',
  })
  @IsString()
  @Length(6, 6, { message: '短信验证码必须是6位数字' })
  @Matches(/^\d{6}$/, { message: '短信验证码必须是6位数字' })
  smsCode: string;

  @ApiProperty({
    description: '登录密码',
    example: 'password123',
  })
  @IsString()
  @Length(6, 32, { message: '密码长度必须在6-32位之间' })
  password: string;
}
