Skip to content

Commit

Permalink
feat: ✨ Add validation decorators to UserTaskDto
Browse files Browse the repository at this point in the history
  • Loading branch information
zhumeisongsong committed Dec 9, 2024
1 parent 2ef1c11 commit d2ba8cb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libs/tasks/interface-adapters/src/lib/dto/user-task.dto.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
import { Field, ID, ObjectType } from '@nestjs/graphql';
import { UserDto } from '@users/interface-adapters';
import { IsDate, IsNotEmpty, IsOptional, IsUUID } from 'class-validator';

import { TaskDto } from './task.dto';

@ObjectType()
export class UserTaskDto {
@Field(() => ID)
@IsNotEmpty()
@IsUUID()
id: string;

@Field(() => Date)
@IsNotEmpty()
@IsDate()
createdAt: Date;

@Field(() => Date, { nullable: true })
@IsOptional()
@IsDate()
updatedAt: Date | null;

@Field(() => String)
@IsNotEmpty()
@IsUUID()
taskId: string;

@Field(() => TaskDto, { nullable: true })
@IsOptional()
task: TaskDto | null;

@Field(() => String)
@IsNotEmpty()
@IsUUID()
userId: string;

@Field(() => UserDto, { nullable: true })
@IsOptional()
user: UserDto | null;

constructor(
Expand Down

0 comments on commit d2ba8cb

Please sign in to comment.