[박한솔] 비밀번호 재수정 버그 수정 및 타입 분류#60
Open
hansol-woff wants to merge 2 commits into
Open
Conversation
Bang-Kyungmin
approved these changes
Dec 31, 2024
Bang-Kyungmin
left a comment
Collaborator
There was a problem hiding this comment.
대체적으로 잘 수정된 것 같습니다 👍
| <div className="register-container slide-from-right"> | ||
| <form noValidate onSubmit={handleSubmit(onSubmit)}> | ||
| {signUpFormat.map((userInformation) => ( | ||
| {signUpFormat.map((userInformation: SignUpInputFormat) => ( |
Collaborator
There was a problem hiding this comment.
여기서 SignUpInputFormat 타입을 단언해주었기 때문에 아래에 as UserSignUpFormValueKey 같은 타입단언들은 불필요합니다. 왜냐하면 SignUpInputFormat 내에 이미 id는 UserSignUpFormValueKey 타입으로 선언되어있기 때문입니다!
| message: '비밀번호는 8자리 이상이며 숫자와 특수문자를 포함해야 합니다.', | ||
| }, | ||
| validate: (value, formValues) => | ||
| formValues.passwordConfirm !== '' |
Collaborator
There was a problem hiding this comment.
특수한 목적이 있는 게 아니면 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,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
작업내역
참고사항