From b9603205e93f0e1734246e1673586618d183aac8 Mon Sep 17 00:00:00 2001 From: hobiJeong Date: Fri, 8 Mar 2024 03:04:50 +0900 Subject: [PATCH] modify(#325): setting constraints with help me board constant --- .../helpMeBoard/help-me-board-page-query.dto.ts | 15 ++++++++++++--- src/boards/dto/helpMeBoard/help-me-board.dto.ts | 7 ++++++- .../dto/helpMeBoard/update.help.me.board.dto.ts | 5 +++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/boards/dto/helpMeBoard/help-me-board-page-query.dto.ts b/src/boards/dto/helpMeBoard/help-me-board-page-query.dto.ts index 13457aa6..3233268c 100644 --- a/src/boards/dto/helpMeBoard/help-me-board-page-query.dto.ts +++ b/src/boards/dto/helpMeBoard/help-me-board-page-query.dto.ts @@ -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({ @@ -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({ diff --git a/src/boards/dto/helpMeBoard/help-me-board.dto.ts b/src/boards/dto/helpMeBoard/help-me-board.dto.ts index 949fb912..3fda007c 100644 --- a/src/boards/dto/helpMeBoard/help-me-board.dto.ts +++ b/src/boards/dto/helpMeBoard/help-me-board.dto.ts @@ -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'; @@ -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: '도와주세요 게시판 글 내용' }) diff --git a/src/boards/dto/helpMeBoard/update.help.me.board.dto.ts b/src/boards/dto/helpMeBoard/update.help.me.board.dto.ts index b9cecbff..ab7c8a3b 100644 --- a/src/boards/dto/helpMeBoard/update.help.me.board.dto.ts +++ b/src/boards/dto/helpMeBoard/update.help.me.board.dto.ts @@ -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()