Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix boolean transformer error #132

Merged
merged 8 commits into from
Feb 16, 2024
Merged

Fix boolean transformer error #132

merged 8 commits into from
Feb 16, 2024

Conversation

hobiJeong
Copy link
Collaborator

@hobiJeong hobiJeong commented Feb 7, 2024

Description

기존에 BooleanString인지 검사하고 boolean으로 transform 하는 로직에 에러가 있었어서 이를 고쳤습니다.

To Reviewer

validator와 transformer중 transformer가 먼저 실행됨.(그 와중에 무조건 어떤 값이든 true로 변환시킴)
먼저 transformer로 mapper 내에 존재하는 값으로 변환시킴('undefined' --> undefined, 'true' --> true, 'false' --> false)
그 후 IsBoolean validator로 검사

Reference Link

typestack/class-transformer#676

Related Issue Link

QYOG-68

API

Method Path 설명 작업(추가, 수정, 삭제)
GET /api/free-posts 자유게시글 pagination 수정
GET /api/notice-posts 공지게시글 pagination 수정

@hobiJeong hobiJeong added Modify 코드 수정(기능상의 수정이 있는 경우) Fix 버그 수정 labels Feb 7, 2024
@hobiJeong hobiJeong requested a review from ohchanghoon February 7, 2024 02:15
@hobiJeong hobiJeong self-assigned this Feb 7, 2024
@hobiJeong hobiJeong requested a review from rrgks6221 as a code owner February 7, 2024 02:15
@modern-agile-team modern-agile-team locked and limited conversation to collaborators Feb 8, 2024
@modern-agile-team modern-agile-team unlocked this conversation Feb 8, 2024
@hobiJeong hobiJeong marked this pull request as draft February 8, 2024 10:21
@hobiJeong hobiJeong marked this pull request as ready for review February 11, 2024 06:08
@hobiJeong
Copy link
Collaborator Author

hobiJeong commented Feb 11, 2024

Description

기존에 BooleanString인지 검사하고 boolean으로 transform 하는 로직에 에러가 있었어서 이를 고쳤습니다.

To Reviewer

validator와 transformer중 transformer가 먼저 실행됨.(그 와중에 무조건 어떤 값이든 true로 변환시킴) 먼저 transformer로 mapper 내에 존재하는 값으로 변환시킴('undefined' --> undefined, 'true' --> true, 'false' --> false) 그 후 IsBoolean validator로 검사

Reference Link

typestack/class-transformer#676

Related Issue Link

QYOG-68

API

Method Path 설명 작업(추가, 수정, 삭제)
GET /api/free-posts 자유게시글 pagination 수정
GET /api/notice-posts 공지게시글 pagination 수정

@rrgks6221 @ohchanghoon pr 다시 열었습니다.

Comment on lines 2 to 6
return value === 'true' || value === '1'
? true
: value === 'false' || value === '0'
? false
: value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

상항연산자가 2개 이상 들어갈때는 if문이 더 단순하게 짜여질 수 있으니 고려해보면 좋을듯합니다.

@@ -0,0 +1,7 @@
export function transformStringToBoolean({ value }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

순수한 js function이여서 testcode 연습겸 짜보면 좋을거같아요

@hobiJeong hobiJeong marked this pull request as draft February 11, 2024 07:20
@hobiJeong hobiJeong marked this pull request as ready for review February 11, 2024 08:57
@hobiJeong hobiJeong requested a review from rrgks6221 February 11, 2024 08:57
@hobiJeong hobiJeong merged commit de934d4 into develop Feb 16, 2024
@hobiJeong hobiJeong deleted the fix/QYOG-68 branch February 16, 2024 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix 버그 수정 Modify 코드 수정(기능상의 수정이 있는 경우)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants