-
Notifications
You must be signed in to change notification settings - Fork 1
게시글 수정 기능 추가 및 작성 폼 확장 #41
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
Conversation
…-sample-monorepo-simple-crud into feature/post-update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코드를 보니 코드 흐름을 직관적으로 보기 위해 수정 후 머지하면 좋을 것 같아요! 🤔
리뷰 내용 반영해주시면 감사하겠습니다! 수정 완료되면 함께 확인해봐요😊
const updatedData: UpdatePostDTO = { | ||
title: formData.get('title') | ||
? validateFormField(formData.get('title'), 'title') | ||
: undefined, | ||
content: formData.get('content') | ||
? validateFormField(formData.get('content'), 'content') | ||
: undefined, | ||
author: formData.get('author') | ||
? validateFormField(formData.get('author'), 'author') | ||
: undefined, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재 updateData 객체를 생성하면서 값 추출과 밸리데이션이 함께 이루어지고 있는데, 객체를 생성하면서 바로 밸리데이션 검증을 진행하기보다는,
밸리데이션을 별도의 단계로 나눠서 유효성 검사를 진행하고, 문제가 없다는 것이 확인된 후에 updateData 객체를 생성하거나 다음 로직을 실행하는 흐름으로 구성하면 가독성이 더 좋아질 것 같습니다. ✨
이렇게 하면 코드 흐름이 더 직관적으로 보이고, 각 단계가 명확하게 구분되어 유지보수에도 도움이 될 것 같아요. 🛠️
이런 방향은 어떠신가요? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@choi1five 님 좋은 리뷰 감사합니다!🙏
피드백 주신 대로 밸리데이션 검증을 별도로 분리하는 방향으로 개선했습니다.
기존에는 updateData
객체를 만들면서 동시에 validateFormField
를 호출했는데,
이를 별도의 유효성 검사 함수getValidatedField
로 분리하여 먼저 검증을 수행한 후,
reduce
를 활용해 validatedData
객체를 생성하는 방식으로 변경했습니다.
getValidatedField
의 경우 공용으로 사용할 수 있어 shared/util
로 분리할 수 있었지만,
아직 post 관련 부분에서만 사용하고 있고 validateFormField
과 함꼐 사용하고 있기 떄문에
entities/post/lib/form-validation.ts
안에 넣어두었습니다.
이렇게 수정하면서 코드의 가독성이 향상되었고, 각 단계가 명확히 구분되었습니다.🔧
혹시 더 개선할 부분이 있다면 피드백 부탁드립니다. 감사합니다! 😊
관련 이슈 번호
Resolves #36
핵심 변경 사항 및 이유
이외 기타 변경 사항
PR 시 참고 사항