import { IsString, IsNotEmpty, Matches, IsOptional } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class RecoverByBackupCodeDto {
  @ApiProperty({ example: 'D24121200001', description: '账户序列号' })
  @IsString()
  @IsNotEmpty({ message: '请提供账户序列号' })
  @Matches(/^D\d{11}$/, { message: '账户序列号格式不正确' })
  accountSequence: string;

  @ApiProperty({ example: 'ABCD-1234-EFGH', description: '恢复码' })
  @IsString()
  @IsNotEmpty({ message: '请提供恢复码' })
  @Matches(/^[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$/, {
    message: '恢复码格式不正确',
  })
  backupCode: string;

  @ApiProperty({ example: 'device-uuid-123', description: '新设备ID' })
  @IsString()
  @IsNotEmpty()
  newDeviceId: string;

  @ApiPropertyOptional({ example: 'iPhone 15 Pro', description: '新设备名称' })
  @IsString()
  @IsOptional()
  deviceName?: string;
}
