From 73a9889ac0fe662ca4270984e8705d27d504f95d Mon Sep 17 00:00:00 2001 From: hobiJeong Date: Fri, 8 Mar 2024 03:09:57 +0900 Subject: [PATCH] modify(#325): setting constraints with mentor review constant --- .../create-mentor-review-request-body.dto.ts | 7 +++++-- .../dtos/mentor-review-page-query-dto.ts | 9 +++++++-- .../mentor-reviews/dtos/mentor-review.dto.ts | 3 +++ .../dtos/mentor-reviews-item-response.dto.ts | 20 ++++++++++++++++++- .../dtos/patch-update-mentor-review.dto.ts | 7 +++++-- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/mentors/mentor-reviews/dtos/create-mentor-review-request-body.dto.ts b/src/mentors/mentor-reviews/dtos/create-mentor-review-request-body.dto.ts index a138d741..f5d0eadb 100644 --- a/src/mentors/mentor-reviews/dtos/create-mentor-review-request-body.dto.ts +++ b/src/mentors/mentor-reviews/dtos/create-mentor-review-request-body.dto.ts @@ -1,9 +1,10 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; -import { IsNotEmpty, IsOptional, ValidateNested } from 'class-validator'; +import { IsOptional, Length, ValidateNested } from 'class-validator'; import { Type } from 'class-transformer'; import { IsNotEmptyObjectAndAllFalse } from '@src/common/decorators/validators/is-not-empty-object-and-all-false.decorator'; import { MentorReviewDto } from '@src/mentors/mentor-reviews/dtos/mentor-review.dto'; import { CreateMentorReviewChecklistRequestBodyDto } from '@src/mentors/mentor-reviews/dtos/create-mentor-review-checklist-request-body.dto'; +import { MENTOR_REVIEW_REVIEW_LENGTH } from '@src/mentors/mentor-reviews/constants/mentor-review.constant'; export class CreateMentorReviewRequestBodyDto implements Partial @@ -19,8 +20,10 @@ export class CreateMentorReviewRequestBodyDto @ApiPropertyOptional({ description: '멘토 리뷰 내용', + minLength: MENTOR_REVIEW_REVIEW_LENGTH.MIN, + maxLength: MENTOR_REVIEW_REVIEW_LENGTH.MAX, }) @IsOptional() - @IsNotEmpty() + @Length(MENTOR_REVIEW_REVIEW_LENGTH.MIN, MENTOR_REVIEW_REVIEW_LENGTH.MAX) review?: string; } diff --git a/src/mentors/mentor-reviews/dtos/mentor-review-page-query-dto.ts b/src/mentors/mentor-reviews/dtos/mentor-review-page-query-dto.ts index 0d958019..b5dfea66 100644 --- a/src/mentors/mentor-reviews/dtos/mentor-review-page-query-dto.ts +++ b/src/mentors/mentor-reviews/dtos/mentor-review-page-query-dto.ts @@ -1,17 +1,19 @@ import { ApiPropertyOptional } from '@nestjs/swagger'; -import { IsBoolean, IsEnum, IsNotEmpty, IsOptional } from 'class-validator'; +import { IsBoolean, IsEnum, IsOptional, Length } from 'class-validator'; import { PageQueryDto } from '@src/common/dto/page-query.dto'; import { SortOrder } from '@src/common/constants/sort-order.enum'; import { IsPositiveInt } from '@src/common/decorators/validators/is-positive-int.decorator'; import { MentorReviewOrderField } from '@src/mentors/mentor-reviews/constants/mentor-review-order-field.enum'; import { Transform } from 'class-transformer'; import { stringToBoolean } from '@src/common/decorators/transformer/string-to-boolean.transformer'; +import { MENTOR_REVIEW_REVIEW_LENGTH } from '@src/mentors/mentor-reviews/constants/mentor-review.constant'; export class MentorReviewPageQueryDto extends PageQueryDto { @ApiPropertyOptional({ description: '리뷰 고유 ID 필터링', format: 'integer', + minimum: 1, }) @IsOptional() @IsPositiveInt() @@ -20,6 +22,7 @@ export class MentorReviewPageQueryDto extends PageQueryDto { @ApiPropertyOptional({ description: '멘티 고유 ID 필터링', format: 'integer', + minimum: 1, }) @IsOptional() @IsPositiveInt() @@ -107,9 +110,11 @@ export class MentorReviewPageQueryDto extends PageQueryDto { @ApiPropertyOptional({ description: '리뷰 내용 필터링', + minLength: MENTOR_REVIEW_REVIEW_LENGTH.MIN, + maxLength: MENTOR_REVIEW_REVIEW_LENGTH.MAX, }) @IsOptional() - @IsNotEmpty() + @Length(MENTOR_REVIEW_REVIEW_LENGTH.MIN, MENTOR_REVIEW_REVIEW_LENGTH.MAX) review?: string; @ApiPropertyOptional({ diff --git a/src/mentors/mentor-reviews/dtos/mentor-review.dto.ts b/src/mentors/mentor-reviews/dtos/mentor-review.dto.ts index 03ec4eb6..bbf42c25 100644 --- a/src/mentors/mentor-reviews/dtos/mentor-review.dto.ts +++ b/src/mentors/mentor-reviews/dtos/mentor-review.dto.ts @@ -1,5 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; import { MentorReview } from '@src/entities/MentorReview'; +import { MENTOR_REVIEW_REVIEW_LENGTH } from '@src/mentors/mentor-reviews/constants/mentor-review.constant'; import { Exclude } from 'class-transformer'; export class MentorReviewDto @@ -30,6 +31,8 @@ export class MentorReviewDto description: '멘티가 작성한 리뷰', nullable: true, type: () => String, + minLength: MENTOR_REVIEW_REVIEW_LENGTH.MIN, + maxLength: MENTOR_REVIEW_REVIEW_LENGTH.MAX, }) review: string | null; diff --git a/src/mentors/mentor-reviews/dtos/mentor-reviews-item-response.dto.ts b/src/mentors/mentor-reviews/dtos/mentor-reviews-item-response.dto.ts index ea7d9571..c06e9924 100644 --- a/src/mentors/mentor-reviews/dtos/mentor-reviews-item-response.dto.ts +++ b/src/mentors/mentor-reviews/dtos/mentor-reviews-item-response.dto.ts @@ -1,7 +1,14 @@ import { ApiProperty } from '@nestjs/swagger'; import { UserImage } from '@src/entities/UserImage'; import { UserIntro } from '@src/entities/UserIntro'; +import { MENTOR_REVIEW_REVIEW_LENGTH } from '@src/mentors/mentor-reviews/constants/mentor-review.constant'; import { MentorReviewDto } from '@src/mentors/mentor-reviews/dtos/mentor-review.dto'; +import { + USER_CAREER_LENGTH, + USER_CUSTOM_CATEGORY_LENGTH, + USER_NAME_LENGTH, + USER_SHORT_INTRO_LENGTH, +} from '@src/users/constants/user.constant'; import { UserInfoDto } from '@src/users/dtos/user-info.dto'; import { Exclude } from 'class-transformer'; @@ -17,16 +24,22 @@ class UserIntroDto { @ApiProperty({ description: '커스텀 카테고리', + minLength: USER_CUSTOM_CATEGORY_LENGTH.MIN, + maxLength: USER_CUSTOM_CATEGORY_LENGTH.MAX, }) customCategory: string; @ApiProperty({ description: '유저 커리어', + minLength: USER_CAREER_LENGTH.MIN, + maxLength: USER_CAREER_LENGTH.MAX, }) career: string; @ApiProperty({ description: '멘토 소개', + minLength: USER_SHORT_INTRO_LENGTH.MIN, + maxLength: USER_SHORT_INTRO_LENGTH.MAX, }) shortIntro: string; } @@ -40,16 +53,19 @@ class Mentee implements Pick { @ApiProperty({ description: '유저 이름', + minLength: USER_NAME_LENGTH.MIN, + maxLength: USER_NAME_LENGTH.MAX, }) name: string; @ApiProperty({ description: '유저 랭크', + format: 'integer', }) rank: number; @ApiProperty({ - description: '유저 랭크', + description: '유저 이미지 객체', }) userImage: UserImageDto; @@ -80,6 +96,8 @@ export class MentorReviewsItemResponseDto description: '멘티가 작성한 리뷰', nullable: true, type: () => String, + minLength: MENTOR_REVIEW_REVIEW_LENGTH.MIN, + maxLength: MENTOR_REVIEW_REVIEW_LENGTH.MAX, }) review: string | null; diff --git a/src/mentors/mentor-reviews/dtos/patch-update-mentor-review.dto.ts b/src/mentors/mentor-reviews/dtos/patch-update-mentor-review.dto.ts index 86211603..6b99ab09 100644 --- a/src/mentors/mentor-reviews/dtos/patch-update-mentor-review.dto.ts +++ b/src/mentors/mentor-reviews/dtos/patch-update-mentor-review.dto.ts @@ -1,8 +1,9 @@ import { ApiPropertyOptional } from '@nestjs/swagger'; import { Type } from 'class-transformer'; -import { IsNotEmpty, IsOptional, ValidateNested } from 'class-validator'; +import { IsOptional, Length, ValidateNested } from 'class-validator'; import { IsNotEmptyObjectAndAllFalse } from '@src/common/decorators/validators/is-not-empty-object-and-all-false.decorator'; import { CreateMentorReviewChecklistRequestBodyDto } from '@src/mentors/mentor-reviews/dtos/create-mentor-review-checklist-request-body.dto'; +import { MENTOR_REVIEW_REVIEW_LENGTH } from '@src/mentors/mentor-reviews/constants/mentor-review.constant'; export class PatchUpdateMentorReviewDto { @ApiPropertyOptional({ @@ -17,8 +18,10 @@ export class PatchUpdateMentorReviewDto { @ApiPropertyOptional({ description: '멘토 리뷰 내용', + minLength: MENTOR_REVIEW_REVIEW_LENGTH.MIN, + maxLength: MENTOR_REVIEW_REVIEW_LENGTH.MAX, }) @IsOptional() - @IsNotEmpty() + @Length(MENTOR_REVIEW_REVIEW_LENGTH.MIN, MENTOR_REVIEW_REVIEW_LENGTH.MAX) review?: string; }