Skip to content

Commit

Permalink
modify(#325): setting constraints with help me board constant
Browse files Browse the repository at this point in the history
  • Loading branch information
hobiJeong committed Mar 7, 2024
1 parent a467823 commit b960320
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
15 changes: 12 additions & 3 deletions src/boards/dto/helpMeBoard/help-me-board-page-query.dto.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsBoolean, IsEnum, IsNotEmpty, IsOptional } from 'class-validator';
import {
IsBoolean,
IsEnum,
IsNotEmpty,
IsOptional,
Length,
} from 'class-validator';
import { PageQueryDto } from '@src/common/dto/page-query.dto';
import { IsPositiveInt } from '@src/common/decorators/validators/is-positive-int.decorator';
import { HelpMeBoardOrderField } from '@src/boards/constants/help-me-board-order-field.enum';
import { HelpMeBoardOrderField } from '@src/boards/constants/help-me-board/help-me-board-order-field.enum';
import { SortOrder } from '@src/common/constants/sort-order.enum';
import { stringToBoolean } from '@src/common/decorators/transformer/string-to-boolean.transformer';
import { Transform } from 'class-transformer';
import { HELP_ME_BOARD_HEAD_LENGTH } from '@src/boards/constants/help-me-board/help-me-board.constant';

export class HelpMeBoardPageQueryDto extends PageQueryDto {
@ApiPropertyOptional({
Expand All @@ -26,9 +33,11 @@ export class HelpMeBoardPageQueryDto extends PageQueryDto {

@ApiPropertyOptional({
description: '제목 필터링',
minLength: HELP_ME_BOARD_HEAD_LENGTH.MIN,
maxLength: HELP_ME_BOARD_HEAD_LENGTH.MAX,
})
@IsOptional()
@IsNotEmpty()
@Length(HELP_ME_BOARD_HEAD_LENGTH.MIN, HELP_ME_BOARD_HEAD_LENGTH.MAX)
head?: string;

@ApiPropertyOptional({
Expand Down
7 changes: 6 additions & 1 deletion src/boards/dto/helpMeBoard/help-me-board.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { HELP_ME_BOARD_HEAD_LENGTH } from '@src/boards/constants/help-me-board/help-me-board.constant';
import { HelpMeBoard } from '@src/entities/HelpMeBoard';
import { Exclude } from 'class-transformer';

Expand All @@ -22,7 +23,11 @@ export class HelpMeBoardDto
})
userId: number;

@ApiProperty({ description: '도와주세요 게시판 글 제목' })
@ApiProperty({
description: '도와주세요 게시판 글 제목',
minLength: HELP_ME_BOARD_HEAD_LENGTH.MIN,
maxLength: HELP_ME_BOARD_HEAD_LENGTH.MAX,
})
head: string;

@ApiProperty({ description: '도와주세요 게시판 글 내용' })
Expand Down
5 changes: 3 additions & 2 deletions src/boards/dto/helpMeBoard/update.help.me.board.dto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { IsNumber, IsString } from 'class-validator';
import { HELP_ME_BOARD_HEAD_LENGTH } from '@src/boards/constants/help-me-board/help-me-board.constant';
import { IsNumber, IsString, Length } from 'class-validator';

export class UpdateHelpMeBoardDto {
@IsString()
@Length(HELP_ME_BOARD_HEAD_LENGTH.MIN, HELP_ME_BOARD_HEAD_LENGTH.MAX)
head: string;

@IsString()
Expand Down

0 comments on commit b960320

Please sign in to comment.