chore(deps): add zod and nestjs-zod for schema validation
This commit is contained in:
@@ -1,31 +1,16 @@
|
||||
import { IsString, IsNotEmpty, MinLength, IsEmail, IsOptional } from 'class-validator';
|
||||
import { z } from "zod";
|
||||
|
||||
export class LoginDto {
|
||||
@IsString()
|
||||
@IsNotEmpty({ message: '用户名不能为空' })
|
||||
username: string;
|
||||
export const LoginDto = z.object({
|
||||
username: z.string().min(1, "用户名不能为空"),
|
||||
password: z.string().min(1, "密码不能为空"),
|
||||
});
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty({ message: '密码不能为空' })
|
||||
password: string;
|
||||
}
|
||||
export const ChangePasswordDto = z.object({
|
||||
currentPassword: z.string().min(1, "当前密码不能为空"),
|
||||
newPassword: z.string().min(6, "新密码长度至少为6位"),
|
||||
});
|
||||
|
||||
export class ChangePasswordDto {
|
||||
@IsString()
|
||||
@IsNotEmpty({ message: '当前密码不能为空' })
|
||||
currentPassword: string;
|
||||
|
||||
@IsString()
|
||||
@MinLength(6, { message: '新密码长度至少为6位' })
|
||||
newPassword: string;
|
||||
}
|
||||
|
||||
export class UpdateProfileDto {
|
||||
@IsString()
|
||||
@IsNotEmpty({ message: '姓名不能为空' })
|
||||
name: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsEmail({}, { message: '邮箱格式不正确' })
|
||||
email?: string;
|
||||
}
|
||||
export const UpdateProfileDto = z.object({
|
||||
name: z.string().min(1, "姓名不能为空"),
|
||||
email: z.string().email("邮箱格式不正确").optional(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user