Skip to content

[BE-fix] boolean 필드에 문자열이 true로 변환되어 통과하던 문제 수정 - #28

Merged
2eceon merged 1 commit into
devfrom
fix/BE-strict-boolean
Oct 9, 2026
Merged

2eceon merged 1 commit into
devfrom
fix/BE-strict-boolean

Conversation

@2eceon

@2eceon 2eceon commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

💡 개요

boolean 필드에 "false" 같은 문자열을 보내면 true로 바뀌어 통과하던 문제를 고칩니다.
자기선언 동의에 "false"를 보내면 동의한 것으로 저장될 수 있었습니다.

🐞 원인

  • 전역 ValidationPipe의 enableImplicitConversion: true가 검증 전에 값을 Boolean(값)으로 변환
  • 그래서 "false", "YES", 1 등이 모두 true가 되어 @IsBoolean()을 통과

📌 변경 사항

  • 변환 전 원래 값으로 검사하는 @StrictBoolean() 데코레이터 추가 (src/core)
  • 적용: 자기선언 동의 3종, 질문 템플릿 required·evaluationEnabled
  • 전역 설정(main.ts)은 변경 없음
  • 이제 진짜 true/false만 통과하고, 나머지는 400

📖 참고

  • 프론트가 진짜 boolean을 보내고 있다면 동작 변화 없음
  • 레거시 DTO 3곳(consent 2, employment 1)에도 같은 문제가 있지만 수정 금지 영역이라 레거시 정리 때 처리

✅ 검증

  • build 통과, test 219개 통과 (신규 19개)
  • 전역 ValidationPipe와 같은 설정으로 실제 DTO가 문자열 boolean을 거부하는지 확인

전역 ValidationPipe의 enableImplicitConversion 때문에 @isboolean 필드에
"false"·"YES"·1 같은 값이 Boolean(값)으로 바뀌어 통과했다.
자기선언 동의에 "false" 문자열을 보내면 동의한 것으로 저장될 수 있었다.

- 변환 전 원래 값으로 검사하는 @StrictBoolean() 데코레이터 추가 (src/core)
- 자기선언 동의 3종, 질문 템플릿 required·evaluationEnabled에 적용
- 전역 설정(main.ts)은 변경하지 않음

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@2eceon
2eceon requested a review from haeunjeon0410 October 9, 2026 11:54
@2eceon 2eceon self-assigned this Oct 9, 2026
@2eceon 2eceon added the 🐞FIX Fix label Oct 9, 2026
@2eceon
2eceon merged commit 2b78e17 into dev Oct 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant