Skip to content

[박한솔] 비밀번호 재수정 버그 수정 및 타입 분류#60

Open
hansol-woff wants to merge 2 commits into
registerfrom
register-PR
Open

[박한솔] 비밀번호 재수정 버그 수정 및 타입 분류#60
hansol-woff wants to merge 2 commits into
registerfrom
register-PR

Conversation

@hansol-woff

@hansol-woff hansol-woff commented Dec 30, 2024

Copy link
Copy Markdown
Member

작업내역

  • 비밀번호 확인을 통과한 이후에 수정하면 이에 대한 호환성 체크가 제대로 이뤄지지 않았던 부분 수정
  • 타입을 별도로 지정하여 파일로 분리
  • 지난번 피드백 주신 내용에 이어서 수정했던 부분의 PR입니다.

참고사항

  • 프로젝트 마무리 기간으로 인해 merge를 먼저 진행하였으며, 이번에 드리는 PR요청 역시 작업을 임의로 마무리했던 부분이라는 점 양해 부탁드립니다..!
  • 이미 main의 작업에 더 최신 코드가 반영된 상태라 이 PR내용으로 merge 하지 않고 close할 예정입니다.

@hansol-woff hansol-woff added the bug 버그 관련 label Dec 30, 2024
@hansol-woff hansol-woff added this to the 테스트 milestone Dec 30, 2024
@hansol-woff hansol-woff self-assigned this Dec 30, 2024
@hansol-woff hansol-woff added the reviewer request 리뷰어님께 코드리뷰요청 label Dec 30, 2024

@Bang-Kyungmin Bang-Kyungmin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

대체적으로 잘 수정된 것 같습니다 👍

<div className="register-container slide-from-right">
<form noValidate onSubmit={handleSubmit(onSubmit)}>
{signUpFormat.map((userInformation) => (
{signUpFormat.map((userInformation: SignUpInputFormat) => (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

여기서 SignUpInputFormat 타입을 단언해주었기 때문에 아래에 as UserSignUpFormValueKey 같은 타입단언들은 불필요합니다. 왜냐하면 SignUpInputFormat 내에 이미 id는 UserSignUpFormValueKey 타입으로 선언되어있기 때문입니다!

Comment thread src/data/signUpFormat.tsx
message: '비밀번호는 8자리 이상이며 숫자와 특수문자를 포함해야 합니다.',
},
validate: (value, formValues) =>
formValues.passwordConfirm !== ''

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

특수한 목적이 있는 게 아니면 formValues.passwordConfirm !== '' 처럼 문자열을 검사하는 것 보다는 !formValues.passwordConfirm 처럼 truthy falsy 만 검사하는게 더 일반적이고 안전합니다.

추가로 이 삼항식을 풀어보면

  • formValues.passwordConfirm === ''면 true이다.
  • formValues.passwordConfirm !== ''면
    • value === formValues.passwordConfirm 를 만족하면 true
    • value !== formValues.passwordConfirm 면 '비밀번호 확인란과 일치하지 않습니다.' 문자열 반환

이렇게 되겠네요.
위에서 이야기한대로 빈 문자열 비교식을 수정하고 하나씩 조건을 나열해보면 아래와 같이 조건을 적을 수도 있겠습니다.

!formValues.passwordConfirm || value === formValues.passwordConfirm ||  '비밀번호 확인란과 일치하지 않습니다.'
formValues.passwordConfirm !== ''
  ? value === formValues.passwordConfirm ||'비밀번호 확인란과 일치하지 않습니다.'
  : true,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 버그 관련 reviewer request 리뷰어님께 코드리뷰요청

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants