Skip to content

Fix(web): Ocr Validation 수정#325

Open
huniversal wants to merge 10 commits intodevelopfrom
fix/ocr-validation/#314
Open

Fix(web): Ocr Validation 수정#325
huniversal wants to merge 10 commits intodevelopfrom
fix/ocr-validation/#314

Conversation

@huniversal
Copy link
Copy Markdown
Contributor

📌 Summary

📚 Tasks

  • setValueshuldValidate 추가
  • visaStartDate 변경 시 visaEcpiredAt 재검증 트리거 추가

👀 To Reviewer

기존 onboarding form에는 mode: onChange로 설정이 되어 있었습니다.
근데 mode: onChange는 사용자가 input을 직접 타이핑하거나 변경할때 validation이 실행되기 때문에
ocr를 통해 값을 받는 경우에는 사용자의 인터랙션 없이 setValue로 값을 주입하기 때문에 mode: onChange가 동작하지 않았던거 같아요

그래서 shouldValidate: true 옵션을 통해 폼이 값을 주입한 이후에 필드에 등록된 validate를 사용자가 직접 입력한 것처럼 트리거 하도록 처리하였습니당

비자 발급일에 따른 비자 만료일 재검증 로직

기존에는 비자 시작일을 변경하더라도 그에 따른 비자 만료일에서 validation이 동작하지 않는 이슈가 있었고
유저가 값을 직접 지우거나 다시 입력해야만 에러 문구가 떴습니다.
image

기존 온보딩 form 같은 경우 해당 필드 자체가 변경될 때만 validate를 재실행하기 때문에
useWatch 대신 getValue를 사용하여 비자 시작일이 변경될 때 trigger를 실행하도록 하였습니다.

📸 Screenshot

업로드 데이터
image

validation 적용

2026-04-10.15.53.03.mov

비자 시작일 변경에 따른 비자 만료일 트리거 적용

2026-04-10.15.57.32.mov

@huniversal huniversal linked an issue Apr 10, 2026 that may be closed by this pull request
1 task
@huniversal huniversal requested a review from a team as a code owner April 10, 2026 07:24
@github-actions github-actions bot added the 🐛 FIX 문제 해결 작업 label Apr 10, 2026
Comment on lines +29 to +34
useEffect(() => {
if (getValues('visaExpiredAt')) {
trigger('visaExpiredAt');
}
}, [visaStartDate, trigger, getValues]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

엇 visaStartDate가 바뀔 때도 트리거 해야하는군요??
제가 담당한 부분은 visaType 변경 시 visaExpiredAt의 validate가 트리거 되는 부분인데요

합치는 작업 필요할 거 같아요!
#326

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

오히려 visaType은 괜찮은지 궁금하네요?! 검증이 된 상태로 visaType이 변경된다면 어떻게 되는지 확인 부탁드릴게요!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

현재는 비자타입 변경에 따른 visaExpiredAt 트리거 변경은 없습니다!!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

validate가 적용된 상태로 visa 타입이 변경되었을 때 문제가 없는지가 궁금했어요. 그래서 useEffect에 visaType을 넣을 필요도 없는지도요!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

2026-04-12.12.45.11.mov

아 useEffect에 visaType를 넣지 않으면 비자 타입이 바뀔때 validation이 적용되지 않습니다!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

그러면 visaType을 deps 배열에 넣는게 맞아보이네요???

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

네 visaType도 배열에 추가할게요!!

Copy link
Copy Markdown
Member

@jeonghoon11 jeonghoon11 left a comment

Choose a reason for hiding this comment

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

코맨트만 한번 확인 부탁드려요!

const { control } = useFormContext<OnboardingForm>();
const visaType = useWatch({ control, name: 'visaType' });
const { control, getValues, trigger } = useFormContext<OnboardingForm>();
// const visaType = useWatch({ control, name: 'visaType' });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

주석은 삭제해주세요!

Comment on lines +29 to +34
useEffect(() => {
if (getValues('visaExpiredAt')) {
trigger('visaExpiredAt');
}
}, [visaStartDate, trigger, getValues]);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

오히려 visaType은 괜찮은지 궁금하네요?! 검증이 된 상태로 visaType이 변경된다면 어떻게 되는지 확인 부탁드릴게요!

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 13, 2026

Deploying kareer-client with  Cloudflare Pages  Cloudflare Pages

Latest commit: d64b681
Status: ✅  Deploy successful!
Preview URL: https://ce93c4e9.kareer-client.pages.dev
Branch Preview URL: https://fix-ocr-validation--314.kareer-client.pages.dev

View logs

setValue('birthDate', data.data?.birthDate ?? '', {
shouldValidate: true,
});
setValue('name', data.data?.fullName ?? '');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

헷갈리는데 PR에 작성하신것 처럼

shouldValidate: true 옵션을 통해 폼이 값을 주입한 이후에 필드에 등록된 validate를 사용자가 직접 입력한 것처럼 트리거 하도록 처리하였습니당

이 내용은 다시 필요 없어진건가요??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

이번 이슈에서 총 2가지의 작업을 진행했어요!

  1. OCR로 받은 데이터값에 Validation이 적용되지 않는 이슈
  2. 비자 타입 및 비자 시작일이 변경되는 경우 비자 만료일에 Validation이 바로 적용되지 않는 이슈

shouldValidate옵션은 1번쨰 이슈를 해결하기 위해 OCR값이 채워질때 유효성에 걸리는 순간 필드 자체를 즉시 검증하는 역할을 수행합니다.

트리거를 걸어둔 부분은 기존의 비자 타입, 비자 시작&만료일 input을 전부 채워둔 상태에서 비자 타입 및 비자 시작일이 변경되는 경우 유효성을 바로 검증하기 위한 작업을 진행하였어요

그래서 shouldValidate의 옵션도 필요합니다!!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

passport에서 제거하신 이유가 궁금한거였어요! visa에서만 해당 옵션이 필요한건가요??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

네! passport에는 필드 자체가 독립적이라 필요하지 않다고 생각했어요
visa에서만 의존관계이기 때문에 해당 옵션이 필요한 구조인거 같아요

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

passport ocr에도 shouldValidate 옵션을 추가하였습니다!

Copy link
Copy Markdown
Member

@jeonghoon11 jeonghoon11 left a comment

Choose a reason for hiding this comment

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

고생해쓰용~~

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

Labels

🐛 FIX 문제 해결 작업 🦍 훈진

Projects

Development

Successfully merging this pull request may close these issues.

[Fix] OCR Validation 적용

3 participants