refactor: strengthen client boundaries and quality gates
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsEmail, IsIn, IsOptional, IsString, Matches, MaxLength, MinLength } from 'class-validator';
|
||||
|
||||
const emptyToUndefined = ({ value }: { value: unknown }) =>
|
||||
typeof value === 'string' ? value.trim() || undefined : value;
|
||||
|
||||
export class ClientCreateUserDto {
|
||||
@Transform(emptyToUndefined) @IsOptional() @IsString() @MaxLength(100) username?: string;
|
||||
@Transform(emptyToUndefined) @IsOptional() @IsEmail() @MaxLength(200) email?: string;
|
||||
@Transform(emptyToUndefined) @IsOptional() @Matches(/^\+?[0-9-]{6,24}$/) phone?: string;
|
||||
@IsString() @MinLength(1) @MaxLength(100) displayName!: string;
|
||||
@IsString() @MinLength(8) @MaxLength(128) password!: string;
|
||||
@IsOptional() @IsIn(['active', 'disabled']) status?: 'active' | 'disabled';
|
||||
}
|
||||
|
||||
export class ClientUpdateUserDto {
|
||||
@Transform(emptyToUndefined) @IsOptional() @IsString() @MaxLength(100) username?: string;
|
||||
@Transform(emptyToUndefined) @IsOptional() @IsEmail() @MaxLength(200) email?: string;
|
||||
@Transform(emptyToUndefined) @IsOptional() @Matches(/^\+?[0-9-]{6,24}$/) phone?: string;
|
||||
@IsOptional() @IsString() @MinLength(1) @MaxLength(100) displayName?: string;
|
||||
@IsOptional() @IsIn(['active', 'disabled']) status?: 'active' | 'disabled';
|
||||
}
|
||||
|
||||
export class ClientUserStatusDto {
|
||||
@IsIn(['active', 'disabled']) status!: 'active' | 'disabled';
|
||||
}
|
||||
|
||||
export class ClientUserPasswordDto {
|
||||
@IsString() @MinLength(8) @MaxLength(128) password!: string;
|
||||
}
|
||||
Reference in New Issue
Block a user