import { ApiProperty } from '@nestjs/swagger'; import { IsOptional, IsString, Matches, MaxLength, MinLength } from 'class-validator'; export class LoginDto { @ApiProperty({ description: '手机号/邮箱' }) @IsOptional() username: string; @ApiProperty({ description: '密码', example: 'a123456' }) @IsString() @Matches(/^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Za-z])\S*$/, { message: '密码错误' }) @MinLength(6) password: string; @ApiProperty({ description: '验证码标识,手机端不需要' }) @IsOptional() captchaId: string; @ApiProperty({ description: '用户输入的验证码' }) @IsOptional() @MinLength(4) @MaxLength(4) verifyCode: string; } export class RegisterDto { @ApiProperty({ description: '账号' }) @IsString() username: string; @ApiProperty({ description: '密码' }) @IsString() @Matches(/^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Za-z])\S*$/) @MinLength(6) @MaxLength(16) password: string; @ApiProperty({ description: '语言', examples: ['EN', 'ZH'] }) @IsString() lang: string; }