-
Notifications
You must be signed in to change notification settings - Fork 20
Sprint4/효준 #42
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
Sprint4/효준 #42
The head ref may contain hidden characters: "sprint4/\uD6A8\uC900"
Conversation
warning changes when focusout the inputs so we need this process
|
스프리트 미션 하시느라 수고 많으셨어요. |
| const NOINPUT = 0; | ||
| const WRONGINPUT = 1; | ||
| const VALIDINPUT = 2; |
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.
오호 흥미롭네요 에러 코드를 정의하셨군요..?
새로운 도전이네요. 이렇게 문제 풀이하신 수강생님은 처음봅니다 😊😊
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 NOINPUT = 0; | |
| const WRONGINPUT = 1; | |
| const VALIDINPUT = 2; | |
| const ERROR_CODE = { | |
| email: { | |
| NOINPUT: "이메일을 입력해주세요.", | |
| WRONGINPUT: "잘못된 이메일 형식입니다.", | |
| }, | |
| password: { | |
| NOINPUT: "비밀번호를 입력해주세요.", | |
| WRONGINPUT: "비밀번호를 8자 이상 입력해주세요.", | |
| }, | |
| nickname: { | |
| NOINPUT: "닉네임을 입력해주세요.", | |
| }, | |
| checkPassword: { | |
| WRONGINPUT: "비밀번호가 일치하지 않습니다.", | |
| }, | |
| }; |
이렇게 되면 해당되는 에러 코드의 메시지를 한 곳에서 관리할 수 있습니다 😊
| const validators = { | ||
| email: (email) => { | ||
| const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; | ||
|
|
||
| if (email.trim() === "") | ||
| return (NOINPUT); | ||
| else if (!emailRegex.test(email)) | ||
| return (WRONGINPUT); | ||
| return (VALIDINPUT); | ||
| }, | ||
| password: (password) => { | ||
| if (password.length === 0) | ||
| return (NOINPUT); | ||
| else if (password.length < 8) | ||
| return (WRONGINPUT); | ||
| return (VALIDINPUT); | ||
| }, | ||
| nickname: (nickname) => { | ||
| if (nickname.length === 0) | ||
| return (NOINPUT); | ||
| return (VALIDINPUT); | ||
| }, | ||
| checkPassword: (password, checkPassword) => { | ||
| if (password !== checkPassword) | ||
| return (WRONGINPUT); | ||
| return (VALIDINPUT); | ||
| } | ||
| } |
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 validators = { | |
| email: (email) => { | |
| const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; | |
| if (email.trim() === "") | |
| return (NOINPUT); | |
| else if (!emailRegex.test(email)) | |
| return (WRONGINPUT); | |
| return (VALIDINPUT); | |
| }, | |
| password: (password) => { | |
| if (password.length === 0) | |
| return (NOINPUT); | |
| else if (password.length < 8) | |
| return (WRONGINPUT); | |
| return (VALIDINPUT); | |
| }, | |
| nickname: (nickname) => { | |
| if (nickname.length === 0) | |
| return (NOINPUT); | |
| return (VALIDINPUT); | |
| }, | |
| checkPassword: (password, checkPassword) => { | |
| if (password !== checkPassword) | |
| return (WRONGINPUT); | |
| return (VALIDINPUT); | |
| } | |
| } | |
| const signUpFormSchema = { | |
| email: { | |
| validate: (email) => { | |
| if (email.trim() === "") return "NOINPUT"; | |
| if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) return "WRONGINPUT"; | |
| return "VALIDINPUT"; | |
| }, | |
| message: { | |
| NOINPUT: "이메일을 입력해주세요.", | |
| WRONGINPUT: "잘못된 이메일 형식입니다.", | |
| }, | |
| }, | |
| password: { | |
| validate: (password) => { | |
| if (password.trim() === "") return "NOINPUT"; | |
| if (password.length < 8) return "WRONGINPUT"; | |
| return "VALIDINPUT"; | |
| }, | |
| message: { | |
| NOINPUT: "비밀번호를 입력해주세요.", | |
| WRONGINPUT: "비밀번호는 8자 이상이어야 합니다.", | |
| }, | |
| }, | |
| nickname: { | |
| validate: (nickname) => { | |
| if (nickname.trim() === "") return "NOINPUT"; | |
| return "VALIDINPUT"; | |
| }, | |
| message: { | |
| NOINPUT: "닉네임을 입력해주세요.", | |
| }, | |
| }, | |
| checkPassword: { | |
| validate: (password, checkPassword) => { | |
| if (password !== checkPassword) return "WRONGINPUT"; | |
| return "VALIDINPUT"; | |
| }, | |
| message: { | |
| WRONGINPUT: "비밀번호가 일치하지 않습니다.", | |
| }, | |
| }, | |
| }; |
창의적이고 도전적으로 문제를 잘 풀이하셔서 어느 정도 난이도 있는 제안도 잘 수행하실 것 같아서 조심스레 제안드려봅니다 ! 😉
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.
(팁 !)추가로 스키마를 쉽게 작성하기 위한 라이브러리도 존재합니다 !
import Joi from "joi";
const schema = Joi.object({
email: Joi.string().email({ tlds: { allow: false } }).required().messages({
"string.empty": "이메일을 입력해주세요.",
"string.email": "잘못된 이메일 형식입니다.",
}),
password: Joi.string().min(8).required().messages({
"string.empty": "비밀번호를 입력해주세요.",
"string.min": "비밀번호는 8자 이상이어야 합니다.",
}),
nickname: Joi.string().required().messages({
"string.empty": "닉네임을 입력해주세요.",
}),
checkPassword: Joi.any().valid(Joi.ref("password")).required().messages({
"any.only": "비밀번호가 일치하지 않습니다.",
"any.required": "비밀번호 확인을 입력해주세요.",
}),
});라이브러리를 활용하여 더욱 간단하게 스키마와 유효성 검사 로직을 작성하실 수 있습니다 😉😉
|
|
||
| const visibilityConfig = { | ||
| password: { | ||
| showPassword: { |
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.
굿굿 ! 피드백을 적용하셨군요 👍
목적에 더욱 부합된� 이름으로 변경된 것 같아서 뿌듯하네요 😊
|
수고하셨습니다 효준님 ! 리뷰와 관련하여 궁금하신 점은 DM으로 질문주세요 ! 😊 |
요구사항
기본
로그인
회원가입
심화
주요 변경사항
sprint3 미션 feedback 적용
스크린샷
2025-01-05.3.59.07.mov
멘토에게