2022-10-09 22:30:32 +02:00
|
|
|
import { Expose, plainToClass } from "class-transformer";
|
2022-12-01 23:07:49 +01:00
|
|
|
import { IsEmail, IsNotEmpty, IsOptional, IsString } from "class-validator";
|
2022-10-09 22:30:32 +02:00
|
|
|
|
2022-10-10 17:58:42 +02:00
|
|
|
export class UserDTO {
|
2022-10-09 22:30:32 +02:00
|
|
|
@Expose()
|
|
|
|
|
id: string;
|
|
|
|
|
|
|
|
|
|
@Expose()
|
2022-12-01 23:07:49 +01:00
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
username: string;
|
2022-10-09 22:30:32 +02:00
|
|
|
|
|
|
|
|
@Expose()
|
2022-12-01 23:07:49 +01:00
|
|
|
@IsOptional()
|
2022-10-09 22:30:32 +02:00
|
|
|
@IsEmail()
|
|
|
|
|
email: string;
|
|
|
|
|
|
|
|
|
|
@IsNotEmpty()
|
|
|
|
|
@IsString()
|
|
|
|
|
password: string;
|
|
|
|
|
|
2022-12-01 23:07:49 +01:00
|
|
|
@Expose()
|
|
|
|
|
isAdmin: boolean;
|
|
|
|
|
|
2022-10-10 17:58:42 +02:00
|
|
|
from(partial: Partial<UserDTO>) {
|
|
|
|
|
return plainToClass(UserDTO, partial, { excludeExtraneousValues: true });
|
2022-10-09 22:30:32 +02:00
|
|
|
}
|
|
|
|
|
}
|