Files
teamwallet/myteamwallet_backend/src/users/dto/create-user.dto.ts
Bastian Wagner 6bea4f766a first commit
2026-07-31 21:02:47 +02:00

65 lines
1.5 KiB
TypeScript

import { Transform } from 'class-transformer';
import { ApiProperty } from '@nestjs/swagger';
import { Role } from '../../roles/entities/role.entity';
import {
IsEmail,
IsNotEmpty,
IsOptional,
MinLength,
Validate,
} from 'class-validator';
import { Status } from '../../statuses/entities/status.entity';
import { IsNotExist } from '../../utils/validators/is-not-exists.validator';
import { FileEntity } from '../../files/entities/file.entity';
import { IsExist } from '../../utils/validators/is-exists.validator';
export class CreateUserDto {
@ApiProperty({ example: 'test1@example.com' })
@Transform(({ value }) => value?.toLowerCase().trim())
@IsNotEmpty()
@Validate(IsNotExist, ['User'], {
message: 'emailAlreadyExists',
})
@IsEmail()
email: string | null;
@ApiProperty()
@MinLength(6)
password?: string;
provider?: string;
socialId?: string | null;
@ApiProperty({ example: 'John' })
@IsNotEmpty()
firstName: string | null;
@ApiProperty({ example: 'Doe' })
@IsNotEmpty()
lastName: string | null;
@ApiProperty({ type: () => FileEntity })
@IsOptional()
@Validate(IsExist, ['FileEntity', 'id'], {
message: 'imageNotExists',
})
photo?: FileEntity | null;
@ApiProperty({ type: Role })
@Validate(IsExist, ['Role', 'id'], {
message: 'roleNotExists',
})
role?: Role | null;
@ApiProperty({ type: Status })
@Validate(IsExist, ['Status', 'id'], {
message: 'statusNotExists',
})
status?: Status;
hash?: string | null;
linkPlayerId?: number | null;
}