oa_based/src/modules/auth/dto/captcha.dto.ts

48 lines
1.0 KiB
TypeScript
Raw Normal View History

2024-02-28 17:02:46 +08:00
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsEmail, IsInt, IsMobilePhone, IsOptional, IsString } from 'class-validator';
2024-02-28 08:32:35 +08:00
export class ImageCaptchaDto {
@ApiProperty({
required: false,
default: 100,
description: '验证码宽度',
})
@Type(() => Number)
@IsInt()
@IsOptional()
2024-02-28 17:02:46 +08:00
readonly width: number = 100;
2024-02-28 08:32:35 +08:00
@ApiProperty({
required: false,
default: 50,
description: '验证码宽度',
})
@Type(() => Number)
@IsInt()
@IsOptional()
2024-02-28 17:02:46 +08:00
readonly height: number = 50;
2024-02-28 08:32:35 +08:00
}
export class SendEmailCodeDto {
@ApiProperty({ description: '邮箱' })
@IsEmail({}, { message: '邮箱格式不正确' })
2024-02-28 17:02:46 +08:00
email: string;
2024-02-28 08:32:35 +08:00
}
export class SendSmsCodeDto {
@ApiProperty({ description: '手机号' })
@IsMobilePhone('zh-CN', {}, { message: '手机号格式不正确' })
2024-02-28 17:02:46 +08:00
phone: string;
2024-02-28 08:32:35 +08:00
}
export class CheckCodeDto {
@ApiProperty({ description: '手机号/邮箱' })
@IsString()
2024-02-28 17:02:46 +08:00
account: string;
2024-02-28 08:32:35 +08:00
@ApiProperty({ description: '验证码' })
@IsString()
2024-02-28 17:02:46 +08:00
code: string;
2024-02-28 08:32:35 +08:00
}