Skip to content

Commit

Permalink
modify(#325): setting constraints with mentor review constant
Browse files Browse the repository at this point in the history
  • Loading branch information
hobiJeong committed Mar 7, 2024
1 parent a9f37a3 commit 73a9889
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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<MentorReviewDto>
Expand All @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -20,6 +22,7 @@ export class MentorReviewPageQueryDto extends PageQueryDto {
@ApiPropertyOptional({
description: '멘티 고유 ID 필터링',
format: 'integer',
minimum: 1,
})
@IsOptional()
@IsPositiveInt()
Expand Down Expand Up @@ -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({
Expand Down
3 changes: 3 additions & 0 deletions src/mentors/mentor-reviews/dtos/mentor-review.dto.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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;
}
Expand All @@ -40,16 +53,19 @@ class Mentee implements Pick<UserInfoDto, 'id' | 'name' | 'rank'> {

@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;

Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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;
}

0 comments on commit 73a9889

Please sign in to comment.