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

export class RecoverByPhoneDto {
  @ApiProperty({
    example: 'D2512110001',
    description: '账户序列号 (格式: D + YYMMDD + 5位序号)',
  })
  @IsString()
  @Matches(/^D\d{11}$/, {
    message: '账户序列号格式错误，应为 D + 年月日(6位) + 序号(5位)',
  })
  accountSequence: string;

  @ApiProperty({ example: '13800138000' })
  @IsString()
  @Matches(/^1[3-9]\d{9}$/, { message: '手机号格式错误' })
  phoneNumber: string;

  @ApiProperty({ example: '123456' })
  @IsString()
  @Matches(/^\d{6}$/, { message: '验证码格式错误' })
  smsCode: string;

  @ApiProperty()
  @IsString()
  @IsNotEmpty()
  newDeviceId: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  deviceName?: string;
}
