import { IsEmail, IsString, IsOptional, MinLength, MaxLength, Length, Matches } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class RegisterEmailDto {
  @ApiProperty({ description: '邮箱地址', example: 'user@example.com' })
  @IsEmail({}, { message: '邮箱格式无效' })
  email: string;

  @ApiProperty({ description: '6位邮箱验证码', example: '123456' })
  @IsString()
  @Length(6, 6, { message: '验证码必须为6位数字' })
  emailCode: string;

  @ApiProperty({ description: '登录密码 (8-128位)', example: 'Password123!' })
  @IsString()
  @MinLength(8, { message: '密码至少8位' })
  @MaxLength(128)
  password: string;

  @ApiPropertyOptional({ description: '昵称', example: 'John' })
  @IsOptional()
  @IsString()
  @MaxLength(50)
  nickname?: string;

  @ApiPropertyOptional({ description: '推荐码（可选）', example: 'GNX1A2B3' })
  @IsOptional()
  @IsString()
  @Matches(/^[A-Z0-9]{6,20}$/i, { message: '推荐码格式无效' })
  referralCode?: string;
}
