Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const validateD2Expiration = (
return VALIDATION_MESSAGE.VISA.D2_EXPIRATION_IN_PAST;
}

if (expiration < limit) {
if (expiration > limit) {
return VALIDATION_MESSAGE.VISA.D2_EXCEEDS_TWO_YEARS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ const IdentityVisaVerification = () => {
onSuccess: ({ data: passportData }) => {
const { fullName, country, birthDate } = passportData ?? {};

setValue('name', fullName ?? '');
setValue('countryCode', country?.code ?? '');
setValue('birthDate', birthDate ?? '');
setValue('name', fullName ?? '', { shouldValidate: true });
setValue('countryCode', country?.code ?? '', { shouldValidate: true });
setValue('birthDate', birthDate ?? '', { shouldValidate: true });

if (!fullName) {
setError('name', {
Expand Down Expand Up @@ -67,9 +67,11 @@ const IdentityVisaVerification = () => {
onSuccess: ({ data: visaData }) => {
const { visaType, visaStartDate, visaExpiredAt } = visaData ?? {};

setValue('visaType', transformVisaType(visaType ?? '') ?? '');
setValue('visaStartDate', visaStartDate ?? '');
setValue('visaExpiredAt', visaExpiredAt ?? '');
setValue('visaType', transformVisaType(visaType ?? '') ?? '', {
shouldValidate: true,
});
setValue('visaStartDate', visaStartDate ?? '', { shouldValidate: true });
setValue('visaExpiredAt', visaExpiredAt ?? '', { shouldValidate: true });

if (!visaType) {
setError('visaType', {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect } from 'react';
import { Autocomplete } from '@kds/ui';
import { useFormContext, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
Expand All @@ -15,7 +16,7 @@ import * as styles from './visa-info-form-section.css';

const VisaInfoFormSection = () => {
const { t } = useTranslation('onboarding');
const { control } = useFormContext<OnboardingForm>();
const { control, getValues, trigger } = useFormContext<OnboardingForm>();
const visaType = useWatch({ control, name: 'visaType' });
const visaStartDate = useWatch({ control, name: 'visaStartDate' });
const visaExpiredAt = useWatch({ control, name: 'visaExpiredAt' });
Expand All @@ -25,6 +26,12 @@ const VisaInfoFormSection = () => {
option === 'D-2' ? t('options.visaType.d2') : t('options.visaType.d10'),
}));

useEffect(() => {
if (getValues('visaExpiredAt')) {
trigger('visaExpiredAt');
}
}, [visaStartDate, visaType, trigger, getValues]);

Comment on lines +29 to +34
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도 배열에 추가할게요!!

return (
<section className={styles.formSection}>
<FormField
Expand Down Expand Up @@ -73,8 +80,8 @@ const VisaInfoFormSection = () => {
validate: (value) =>
validateIdentityVisaExpirationDate(
value,
visaType as VisaType | undefined,
visaStartDate,
getValues('visaType') as VisaType | undefined,
getValues('visaStartDate'),
),
}}
placeholder={t(
Expand Down
Loading