调整用户名长度4~32,昵称1~30
This commit is contained in:
@@ -3,12 +3,12 @@ import { IsString, Length, Matches, ValidateIf } from "class-validator";
|
|||||||
export class CreateDto {
|
export class CreateDto {
|
||||||
@ValidateIf(o => o.username !== null)
|
@ValidateIf(o => o.username !== null)
|
||||||
@IsString({ message: '用户名不得为空' })
|
@IsString({ message: '用户名不得为空' })
|
||||||
@Length(6, 32, { message: '用户名长度只能为6~32' })
|
@Length(4, 32, { message: '用户名长度只能为4~32' })
|
||||||
username: string | null;
|
username: string | null;
|
||||||
|
|
||||||
@ValidateIf(o => o.nickname !== null)
|
@ValidateIf(o => o.nickname !== null)
|
||||||
@IsString({ message: '昵称不得为空' })
|
@IsString({ message: '昵称不得为空' })
|
||||||
@Length(6, 30, { message: '昵称长度只能为6~30' })
|
@Length(1, 30, { message: '昵称长度只能为1~30' })
|
||||||
nickname: string | null;
|
nickname: string | null;
|
||||||
|
|
||||||
@ValidateIf(o => o.email !== null)
|
@ValidateIf(o => o.email !== null)
|
||||||
@@ -23,7 +23,9 @@ export class CreateDto {
|
|||||||
|
|
||||||
@ValidateIf(o => o.password !== null)
|
@ValidateIf(o => o.password !== null)
|
||||||
@IsString({ message: '密码不得为空' })
|
@IsString({ message: '密码不得为空' })
|
||||||
@Length(6, 32)
|
@Length(6, 32, { message: '密码长度只能为6~32' })
|
||||||
@Matches(/^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};:'",.<>/?]{6,32}$/)
|
@Matches(/^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};:'",.<>/?]{6,32}$/,
|
||||||
|
{ message: '密码必须包含字母和数字,且长度在6~32之间' }
|
||||||
|
)
|
||||||
password: string | null;
|
password: string | null;
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
import { IsString, Length, Matches } from "class-validator";
|
import { IsString, Length, Matches } from "class-validator";
|
||||||
|
|
||||||
export class UpdatePasswordDto {
|
export class UpdatePasswordDto {
|
||||||
@IsString()
|
@IsString({ message: '密码不得为空' })
|
||||||
@Length(6, 32)
|
@Length(6, 32, { message: '密码长度只能为6~32' })
|
||||||
@Matches(/^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};:'",.<>/?]{6,32}$/)
|
@Matches(/^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};:'",.<>/?]{6,32}$/,
|
||||||
|
{ message: '密码必须包含字母和数字,且长度在6~32之间' }
|
||||||
|
)
|
||||||
password: string;
|
password: string;
|
||||||
}
|
}
|
||||||
@@ -2,11 +2,11 @@ import { IsEmail, IsOptional, IsString, Length, Matches } from "class-validator"
|
|||||||
|
|
||||||
export class UpdateDto {
|
export class UpdateDto {
|
||||||
@IsString({ message: '用户名不得为空' })
|
@IsString({ message: '用户名不得为空' })
|
||||||
@Length(6, 32, { message: '用户名长度只能为6~32' })
|
@Length(4, 32, { message: '用户名长度只能为4~32' })
|
||||||
username: string;
|
username: string;
|
||||||
|
|
||||||
@IsString({ message: '昵称不得为空' })
|
@IsString({ message: '昵称不得为空' })
|
||||||
@Length(6, 30, { message: '昵称长度只能为6~30' })
|
@Length(1, 30, { message: '昵称长度只能为1~30' })
|
||||||
nickname: string;
|
nickname: string;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
|
|||||||
Reference in New Issue
Block a user