Skip to content

Conversation

@yoonc01
Copy link
Collaborator

@yoonc01 yoonc01 commented Jan 5, 2025

요구사항

기본

로그인

  • 이메일 input에서 focus out 할 때, 값이 없을 경우 input에 빨강색 테두리와 아래에 “이메일을 입력해주세요.” 빨강색 에러 메세지를 보입니다.
  • 이메일 input에서 focus out 할 때, 이메일 형식에 맞지 않는 경우 input에 빨강색 테두리와 아래에 “잘못된 이메일 형식입니다” 빨강색 에러 메세지를 보입니다.
  • 비밀번호 input에서 focus out 할 때, 값이 없을 경우 아래에 “비밀번호를 입력해주세요.” 에러 메세지를 보입니다
  • 비밀번호 input에서 focus out 할 때, 값이 8자 미만일 경우 아래에 “비밀번호를 8자 이상 입력해주세요.” 에러 메세지를 보입니다.
  • input 에 빈 값이 있거나 에러 메세지가 있으면 ‘로그인’ 버튼은 비활성화 됩니다.
  • input 에 유효한 값을 입력하면 ‘로그인' 버튼이 활성화 됩니다.
  • 활성화된 ‘로그인’ 버튼을 누르면 “/items” 로 이동합니다

회원가입

  • 이메일 input에서 focus out 할 때, 값이 없을 경우 input에 빨강색 테두리와 아래에 “이메일을 입력해주세요.” 빨강색 에러 메세지를 보입니다.
  • 이메일 input에서 focus out 할 때, 이메일 형식에 맞지 않는 경우 input에 빨강색 테두리와 아래에 “잘못된 이메일 형식입니다” 빨강색 에러 메세지를 보입니다.
  • 닉네임 input에서 focus out 할 때, 값이 없을 경우 input에 빨강색 테두리와 아래에 “닉네임을 입력해주세요.” 빨강색 에러 메세지를 보입니다.
  • 비밀번호 input에서 focus out 할 때, 값이 없을 경우 아래에 “비밀번호를 입력해주세요.” 에러 메세지를 보입니다
  • 비밀번호 input에서 focus out 할 때, 값이 8자 미만일 경우 아래에 “비밀번호를 8자 이상 입력해주세요.” 에러 메세지를 보입니다.
  • 비밀번호 input과 비밀번호 확인 input의 값이 다른 경우, 비밀번호 확인 input 아래에 “비밀번호가 일치하지 않습니다..” 에러 메세지를 보입니다.
  • input 에 빈 값이 있거나 에러 메세지가 있으면 ‘회원가입’ 버튼은 비활성화 됩니다.
  • input 에 유효한 값을 입력하면 ‘회원가입' 버튼이 활성화 됩니다.
  • 활성화된 ‘회원가입’ 버튼을 누르면 “/signup” 로 이동합니다

심화

  • 눈 모양 아이콘 클릭시 비밀번호의 문자열이 보이기도 하고, 가려지기도 합니다.
  • 비밀번호의 문자열이 가려질 때는 눈 모양 아이콘에는 사선이 그어져있고, 비밀번호의 문자열이 보일 때는 사선이 없는 눈 모양 아이콘이 보이도록 합니다.

주요 변경사항

sprint3 미션 feedback 적용

스크린샷

2025-01-05.3.59.07.mov

멘토에게

  • 1월 1일과 2일 commit은 제 개인 레포의 내용이었어서 무시하셔도 될 거 같습니다!
  • 에러 메세지가 focus out 될 때 발생하는 이벤트라 input에 유효한 값이 있을 때 버튼 활성화되는 것과 에러 메세지가 있으면 버튼이 비활성화되는 것이 서로 모순되는 거 같습니다. 이 부분을 그래서 비활성화되어 있는 버튼을 눌렀을 떄 다시 유효성을 검사하여 동작하도록 수정하였습니다!

@yoonc01 yoonc01 requested a review from kiJu2 January 5, 2025 07:15
@yoonc01 yoonc01 self-assigned this Jan 5, 2025
@yoonc01 yoonc01 added the 순한맛🐑 마음이 많이 여립니다.. label Jan 5, 2025
@kiJu2
Copy link
Collaborator

kiJu2 commented Jan 7, 2025

스프리트 미션 하시느라 수고 많으셨어요.
학습에 도움 되실 수 있게 꼼꼼히 리뷰 하도록 해보겠습니다. 😊

Comment on lines +1 to +3
const NOINPUT = 0;
const WRONGINPUT = 1;
const VALIDINPUT = 2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

오호 흥미롭네요 에러 코드를 정의하셨군요..?

새로운 도전이네요. 이렇게 문제 풀이하신 수강생님은 처음봅니다 😊😊

Copy link
Collaborator

Choose a reason for hiding this comment

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

(의견/제안) 다음과 같이 하나의 객체에서 다룰 수도 있겠네요 !

Suggested change
const NOINPUT = 0;
const WRONGINPUT = 1;
const VALIDINPUT = 2;
const ERROR_CODE = {
email: {
NOINPUT: "이메일을 입력해주세요.",
WRONGINPUT: "잘못된 이메일 형식입니다.",
},
password: {
NOINPUT: "비밀번호를 입력해주세요.",
WRONGINPUT: "비밀번호를 8자 이상 입력해주세요.",
},
nickname: {
NOINPUT: "닉네임을 입력해주세요.",
},
checkPassword: {
WRONGINPUT: "비밀번호가 일치하지 않습니다.",
},
};

이렇게 되면 해당되는 에러 코드의 메시지를 한 곳에서 관리할 수 있습니다 😊

Comment on lines +18 to +45
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);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

(선택/심화/더 나아가서) 다음과 같이 스키마를 작성해볼 수도 있습니다 !

Suggested change
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: "비밀번호가 일치하지 않습니다.",
},
},
};

창의적이고 도전적으로 문제를 잘 풀이하셔서 어느 정도 난이도 있는 제안도 잘 수행하실 것 같아서 조심스레 제안드려봅니다 ! 😉

Copy link
Collaborator

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: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

굿굿 ! 피드백을 적용하셨군요 👍

목적에 더욱 부합된� 이름으로 변경된 것 같아서 뿌듯하네요 😊

@kiJu2
Copy link
Collaborator

kiJu2 commented Jan 7, 2025

수고하셨습니다 효준님 !
에러 코드를 정의하시고 중앙 집중화하여 유효성 검사를 관리하신 점이 인상깊네요 !
도전적이며, 창의적인 방법으로 훌륭히 문제를 해결하셨습니다 ! 😊😊
시간가는 줄 모르고 즐겁게 코드 리뷰 하였습니다 ! 부디 도움 되었으면 하네요 ㅎㅎㅎ

리뷰와 관련하여 궁금하신 점은 DM으로 질문주세요 ! 😊

@kiJu2 kiJu2 merged commit f12bda3 into codeit-bootcamp-frontend:Basic-윤효준 Jan 7, 2025
@yoonc01 yoonc01 deleted the sprint4/효준 branch January 18, 2025 08:46
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.

2 participants