From 2730009ac4371663b34c73e4f90ea62a70e9521e Mon Sep 17 00:00:00 2001 From: tone <3341154833@qq.com> Date: Mon, 12 May 2025 13:56:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=94=A8=E6=88=B7=E5=90=8D?= =?UTF-8?q?=E9=95=BF=E5=BA=A64=EF=BD=9E32=EF=BC=8C=E6=98=B5=E7=A7=B01?= =?UTF-8?q?=EF=BD=9E30?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/admin/dto/admin-user/create.dto.ts | 10 ++++++---- .../src/admin/dto/admin-user/update-password.dto.ts | 8 +++++--- .../src/admin/dto/admin-user/update.dto.ts | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/tone-page-server/src/admin/dto/admin-user/create.dto.ts b/tone-page-server/src/admin/dto/admin-user/create.dto.ts index 2c998c6..42b2c36 100644 --- a/tone-page-server/src/admin/dto/admin-user/create.dto.ts +++ b/tone-page-server/src/admin/dto/admin-user/create.dto.ts @@ -3,12 +3,12 @@ import { IsString, Length, Matches, ValidateIf } from "class-validator"; export class CreateDto { @ValidateIf(o => o.username !== null) @IsString({ message: '用户名不得为空' }) - @Length(6, 32, { message: '用户名长度只能为6~32' }) + @Length(4, 32, { message: '用户名长度只能为4~32' }) username: string | null; @ValidateIf(o => o.nickname !== null) @IsString({ message: '昵称不得为空' }) - @Length(6, 30, { message: '昵称长度只能为6~30' }) + @Length(1, 30, { message: '昵称长度只能为1~30' }) nickname: string | null; @ValidateIf(o => o.email !== null) @@ -23,7 +23,9 @@ export class CreateDto { @ValidateIf(o => o.password !== null) @IsString({ message: '密码不得为空' }) - @Length(6, 32) - @Matches(/^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};:'",.<>/?]{6,32}$/) + @Length(6, 32, { message: '密码长度只能为6~32' }) + @Matches(/^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};:'",.<>/?]{6,32}$/, + { message: '密码必须包含字母和数字,且长度在6~32之间' } + ) password: string | null; } \ No newline at end of file diff --git a/tone-page-server/src/admin/dto/admin-user/update-password.dto.ts b/tone-page-server/src/admin/dto/admin-user/update-password.dto.ts index 2fac29c..6224bfa 100644 --- a/tone-page-server/src/admin/dto/admin-user/update-password.dto.ts +++ b/tone-page-server/src/admin/dto/admin-user/update-password.dto.ts @@ -1,8 +1,10 @@ import { IsString, Length, Matches } from "class-validator"; export class UpdatePasswordDto { - @IsString() - @Length(6, 32) - @Matches(/^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};:'",.<>/?]{6,32}$/) + @IsString({ message: '密码不得为空' }) + @Length(6, 32, { message: '密码长度只能为6~32' }) + @Matches(/^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};:'",.<>/?]{6,32}$/, + { message: '密码必须包含字母和数字,且长度在6~32之间' } + ) password: string; } \ No newline at end of file diff --git a/tone-page-server/src/admin/dto/admin-user/update.dto.ts b/tone-page-server/src/admin/dto/admin-user/update.dto.ts index 25c0d1a..bf8d841 100644 --- a/tone-page-server/src/admin/dto/admin-user/update.dto.ts +++ b/tone-page-server/src/admin/dto/admin-user/update.dto.ts @@ -2,11 +2,11 @@ import { IsEmail, IsOptional, IsString, Length, Matches } from "class-validator" export class UpdateDto { @IsString({ message: '用户名不得为空' }) - @Length(6, 32, { message: '用户名长度只能为6~32' }) + @Length(4, 32, { message: '用户名长度只能为4~32' }) username: string; @IsString({ message: '昵称不得为空' }) - @Length(6, 30, { message: '昵称长度只能为6~30' }) + @Length(1, 30, { message: '昵称长度只能为1~30' }) nickname: string; @IsOptional()