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

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

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

  @ApiProperty({
    example: 'REGISTER',
    description: '验证码类型',
    enum: ['REGISTER', 'LOGIN', 'BIND', 'RECOVER', 'RESET_PASSWORD'],
  })
  @IsString()
  @IsIn(['REGISTER', 'LOGIN', 'BIND', 'RECOVER', 'RESET_PASSWORD'], {
    message: '无效的验证码类型',
  })
  type: string;
}
