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

export class RegisterDto {
  @ApiProperty({ description: '手机号 (E.164 或大陆格式)', example: '+8613800138000' })
  @IsString()
  @Matches(/^\+?[1-9]\d{6,14}$/, { message: '手机号格式无效' })
  phone: string;

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

  @ApiPropertyOptional({ description: '登录密码 (8-128位), 不传则后端自动生成', example: 'Password123!' })
  @IsOptional()
  @IsString()
  @MinLength(8)
  @MaxLength(128)
  password?: string;

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