first commit
This commit is contained in:
64
myteamwallet_backend/src/users/dto/create-user.dto.ts
Normal file
64
myteamwallet_backend/src/users/dto/create-user.dto.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
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;
|
||||
}
|
||||
62
myteamwallet_backend/src/users/dto/update-user.dto.ts
Normal file
62
myteamwallet_backend/src/users/dto/update-user.dto.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { CreateUserDto } from './create-user.dto';
|
||||
|
||||
import { Transform } from 'class-transformer';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Role } from '../../roles/entities/role.entity';
|
||||
import { IsEmail, 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 UpdateUserDto extends PartialType(CreateUserDto) {
|
||||
@ApiProperty({ example: 'test1@example.com' })
|
||||
@Transform(({ value }) => value?.toLowerCase().trim())
|
||||
@IsOptional()
|
||||
@Validate(IsNotExist, ['User'], {
|
||||
message: 'emailAlreadyExists',
|
||||
})
|
||||
@IsEmail()
|
||||
email?: string | null;
|
||||
|
||||
@ApiProperty()
|
||||
@IsOptional()
|
||||
@MinLength(6)
|
||||
password?: string;
|
||||
|
||||
provider?: string;
|
||||
|
||||
socialId?: string | null;
|
||||
|
||||
@ApiProperty({ example: 'John' })
|
||||
@IsOptional()
|
||||
firstName?: string | null;
|
||||
|
||||
@ApiProperty({ example: 'Doe' })
|
||||
@IsOptional()
|
||||
lastName?: string | null;
|
||||
|
||||
@ApiProperty({ type: () => FileEntity })
|
||||
@IsOptional()
|
||||
@Validate(IsExist, ['FileEntity', 'id'], {
|
||||
message: 'imageNotExists',
|
||||
})
|
||||
photo?: FileEntity | null;
|
||||
|
||||
@ApiProperty({ type: Role })
|
||||
@IsOptional()
|
||||
@Validate(IsExist, ['Role', 'id'], {
|
||||
message: 'roleNotExists',
|
||||
})
|
||||
role?: Role | null;
|
||||
|
||||
@ApiProperty({ type: Status })
|
||||
@IsOptional()
|
||||
@Validate(IsExist, ['Status', 'id'], {
|
||||
message: 'statusNotExists',
|
||||
})
|
||||
status?: Status;
|
||||
|
||||
hash?: string | null;
|
||||
}
|
||||
Reference in New Issue
Block a user