import {
  IsString,
  IsOptional,
  IsNotEmpty,
  Matches,
  IsObject,
  MinLength,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { DeviceNameDto } from './auto-create-account.dto';

/**
 * 跳过短信验证码注册 DTO
 * 用户在收不到验证码时可以选择跳过验证继续注册
 * 注册后 phoneVerified = false，需要后续在 KYC 流程中完成验证
 */
export class RegisterWithoutSmsVerifyDto {
  @ApiProperty({
    example: '13800138000',
    description: '手机号',
  })
  @IsString()
  @IsNotEmpty()
  @Matches(/^1[3-9]\d{9}$/, { message: '手机号格式错误' })
  phoneNumber: string;

  @ApiProperty({
    example: 'Password123',
    description: '登录密码 (6-20位)',
  })
  @IsString()
  @IsNotEmpty()
  @MinLength(6, { message: '密码至少6位' })
  password: string;

  @ApiProperty({
    example: '550e8400-e29b-41d4-a716-446655440000',
    description: '设备唯一标识',
  })
  @IsString()
  @IsNotEmpty()
  deviceId: string;

  @ApiPropertyOptional({
    description: '设备信息 (JSON 对象)',
    example: { model: 'iPhone 15 Pro', platform: 'ios', osVersion: '17.2' },
  })
  @IsOptional()
  @IsObject()
  deviceName?: DeviceNameDto;

  @ApiProperty({
    example: 'SEED01',
    description: '邀请人推荐码 (6-20位大写字母和数字) - 必填',
  })
  @IsString()
  @IsNotEmpty({ message: '推荐码不能为空' })
  @Matches(/^[A-Z0-9]{6,20}$/, { message: '推荐码格式错误' })
  inviterReferralCode: string;
}
