34 lines
828 B
TypeScript
34 lines
828 B
TypeScript
import { IsString, IsNotEmpty, Matches, MinLength } from 'class-validator';
|
|
import { ApiProperty } from '@nestjs/swagger';
|
|
|
|
/**
|
|
* 手机号+密码登录 DTO
|
|
*/
|
|
export class LoginWithPasswordDto {
|
|
@ApiProperty({
|
|
description: '手机号',
|
|
example: '13800138000',
|
|
})
|
|
@IsString()
|
|
@IsNotEmpty({ message: '手机号不能为空' })
|
|
@Matches(/^1[3-9]\d{9}$/, { message: '手机号格式不正确' })
|
|
phoneNumber!: string;
|
|
|
|
@ApiProperty({
|
|
description: '登录密码',
|
|
example: 'password123',
|
|
})
|
|
@IsString()
|
|
@IsNotEmpty({ message: '密码不能为空' })
|
|
@MinLength(6, { message: '密码至少6位' })
|
|
password!: string;
|
|
|
|
@ApiProperty({
|
|
description: '设备ID',
|
|
example: 'device-uuid-12345',
|
|
})
|
|
@IsString()
|
|
@IsNotEmpty({ message: '设备ID不能为空' })
|
|
deviceId!: string;
|
|
}
|