59 lines
1.1 KiB
TypeScript
59 lines
1.1 KiB
TypeScript
import { Transform } from 'class-transformer';
|
|
import {
|
|
ArrayUnique,
|
|
IsArray,
|
|
IsBoolean,
|
|
IsEmail,
|
|
IsOptional,
|
|
IsString,
|
|
IsUUID,
|
|
Matches,
|
|
MaxLength,
|
|
MinLength,
|
|
} from 'class-validator';
|
|
|
|
export class CreateUserDto {
|
|
@Transform(({ value }) =>
|
|
typeof value === 'string' ? value.trim().toLowerCase() : value,
|
|
)
|
|
@IsString()
|
|
@MinLength(3)
|
|
@MaxLength(80)
|
|
@Matches(/^[a-zA-Z0-9._-]+$/)
|
|
username!: string;
|
|
|
|
@Transform(({ value }) =>
|
|
typeof value === 'string' ? value.trim().toLowerCase() : value,
|
|
)
|
|
@IsOptional()
|
|
@IsEmail()
|
|
@MaxLength(320)
|
|
email?: string | null;
|
|
|
|
@IsString()
|
|
@MinLength(12)
|
|
@MaxLength(128)
|
|
password!: string;
|
|
|
|
@Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
|
|
@IsString()
|
|
@MinLength(1)
|
|
@MaxLength(120)
|
|
firstName!: string;
|
|
|
|
@Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
|
|
@IsString()
|
|
@MinLength(1)
|
|
@MaxLength(120)
|
|
lastName!: string;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
mustChangePassword = true;
|
|
|
|
@IsArray()
|
|
@ArrayUnique()
|
|
@IsUUID('4', { each: true })
|
|
roleIds!: string[];
|
|
}
|