Skip to content

Commit

Permalink
feat: epic, story, task 엔티티, DTO에 대해 제약조건 설정
Browse files Browse the repository at this point in the history
- epic
  - name을 1자 이상 10자 이하로 설정
- story
  - title을 1자 이상 100자 이하로 설정
  - point을 1 포인트 이상 100 포인트 이하로 설정
- task
  - title을 1자 이상 100자 이하로 설정
  • Loading branch information
choyoungwoo9 committed Jul 15, 2024
1 parent 19c76f2 commit 0b3bf49
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 6 deletions.
10 changes: 9 additions & 1 deletion backend/src/project/dto/epic/EpicCreateRequest.dto.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { Type } from 'class-transformer';
import { IsEnum, IsNotEmpty, IsString, Matches, ValidateNested } from 'class-validator';
import {
IsEnum,
IsNotEmpty,
IsString,
Length,
Matches,
ValidateNested,
} from 'class-validator';
import { EpicColor } from 'src/project/entity/epic.entity';

class Epic {
@IsString()
@Length(1, 10)
name: string;

@IsEnum(EpicColor)
Expand Down
2 changes: 2 additions & 0 deletions backend/src/project/dto/epic/EpicUpdateRequest.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
IsString,
Matches,
ValidateNested,
Length,
} from 'class-validator';
import { EpicColor } from 'src/project/entity/epic.entity';

Expand All @@ -17,6 +18,7 @@ class Epic {

@IsOptional()
@IsString()
@Length(1, 10)
name?: string;

@IsOptional()
Expand Down
6 changes: 6 additions & 0 deletions backend/src/project/dto/story/StoryCreateRequest.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ import {
IsInt,
IsNotEmpty,
IsString,
Length,
Matches,
Max,
Min,
ValidateNested,
} from 'class-validator';
import { StoryStatus } from 'src/project/entity/story.entity';

class Story {
@IsString()
@Length(1, 100)
title: string;

@IsInt()
@Min(0)
@Max(100)
point: number;

@IsEnum(StoryStatus)
Expand Down
8 changes: 7 additions & 1 deletion backend/src/project/dto/story/StoryUpdateRequest.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {
IsNotEmpty,
IsOptional,
IsString,
Length,
Matches,
Max,
Min,
ValidateNested,
} from 'class-validator';
import { StoryStatus } from 'src/project/entity/story.entity';
Expand All @@ -20,10 +23,13 @@ class Story {

@IsOptional()
@IsString()
@Length(1, 100)
title?: string;

@IsOptional()
@IsInt()
@Min(0)
@Max(100)
point?: number;

@IsOptional()
Expand Down
2 changes: 1 addition & 1 deletion backend/src/project/dto/task/TaskCreateRequest.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function IsOneDecimalPlace(validationOptions?: ValidationOptions) {

class Task {
@IsString()
@Length(0, 100, { message: 'Title must be 100 characters or less' })
@Length(1, 100, { message: 'Title must be 100 characters or less' })
title: string;

@IsOptional()
Expand Down
2 changes: 2 additions & 0 deletions backend/src/project/dto/task/TaskUpdateRequest.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
IsNotEmpty,
IsOptional,
IsString,
Length,
Matches,
ValidateNested,
} from 'class-validator';
Expand All @@ -21,6 +22,7 @@ class Task {

@IsOptional()
@IsString()
@Length(1, 100)
title?: string;

@IsOptional()
Expand Down
2 changes: 1 addition & 1 deletion backend/src/project/entity/epic.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class Epic {
@JoinColumn({ name: 'project_id' })
project: Project;

@Column({ type: 'varchar', length: 255, nullable: false })
@Column({ type: 'varchar', length: 10, nullable: false })
name: string;

@Column({ type: 'varchar', length: 255, nullable: false })
Expand Down
2 changes: 1 addition & 1 deletion backend/src/project/entity/story.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class Story {
@JoinColumn({ name: 'epic_id' })
epic: Epic;

@Column({ type: 'varchar', length: 255, nullable: false })
@Column({ type: 'varchar', length: 100, nullable: false })
title: string;

@Column({ type: 'int', nullable: false })
Expand Down
2 changes: 1 addition & 1 deletion backend/src/project/entity/task.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Task {
@JoinColumn({ name: 'story_id' })
story: Story;

@Column({ type: 'varchar', length: 99, nullable: false })
@Column({ type: 'varchar', length: 100, nullable: false })
title: string;

@Column({ type: 'int', nullable: false })
Expand Down

0 comments on commit 0b3bf49

Please sign in to comment.