generated from fahricansecer/boilerplate-be
78 lines
1.3 KiB
TypeScript
78 lines
1.3 KiB
TypeScript
import {
|
|
IsEmail,
|
|
IsString,
|
|
IsOptional,
|
|
IsBoolean,
|
|
MinLength,
|
|
} from 'class-validator';
|
|
import { ApiPropertyOptional, PartialType } from '@nestjs/swagger';
|
|
|
|
export class CreateUserDto {
|
|
@ApiPropertyOptional({ example: 'user@example.com' })
|
|
@IsEmail()
|
|
email: string;
|
|
|
|
@ApiPropertyOptional({ example: 'password123', minLength: 8 })
|
|
@IsString()
|
|
@MinLength(8)
|
|
password: string;
|
|
|
|
@ApiPropertyOptional({ example: 'John' })
|
|
@IsOptional()
|
|
@IsString()
|
|
firstName?: string;
|
|
|
|
@ApiPropertyOptional({ example: 'Doe' })
|
|
@IsOptional()
|
|
@IsString()
|
|
lastName?: string;
|
|
|
|
@ApiPropertyOptional({ default: true })
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
isActive?: boolean;
|
|
}
|
|
|
|
export class UpdateUserDto extends PartialType(CreateUserDto) {
|
|
@ApiPropertyOptional({ example: 'John' })
|
|
@IsOptional()
|
|
@IsString()
|
|
firstName?: string;
|
|
|
|
@ApiPropertyOptional({ example: 'Doe' })
|
|
@IsOptional()
|
|
@IsString()
|
|
lastName?: string;
|
|
|
|
@ApiPropertyOptional({ default: true })
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
isActive?: boolean;
|
|
}
|
|
|
|
import { Exclude, Expose } from 'class-transformer';
|
|
|
|
@Exclude()
|
|
export class UserResponseDto {
|
|
@Expose()
|
|
id: string;
|
|
|
|
@Expose()
|
|
email: string;
|
|
|
|
@Expose()
|
|
firstName: string | null;
|
|
|
|
@Expose()
|
|
lastName: string | null;
|
|
|
|
@Expose()
|
|
isActive: boolean;
|
|
|
|
@Expose()
|
|
createdAt: Date;
|
|
|
|
@Expose()
|
|
updatedAt: Date;
|
|
}
|