Skip to content

Commit c8c3eef

Browse files
committed
[YS-569] fix: 비대면일 때 상세 주소 유효성 검증 제거
1 parent 0c48065 commit c8c3eef

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/app/upload/hooks/useMatchType.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const useMatchType = ({ setIsOnCampus }: UseMatchTypeProps) => {
2626
setValue('region', null);
2727
setValue('area', null);
2828
setValue('place', null);
29-
setValue('detailedAddress', '');
29+
setValue('detailedAddress', null);
3030
setValue('isOnCampus', false);
3131
setIsOnCampus?.(false);
3232
} else {

src/schema/upload/uploadExperimentPostSchema.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,20 @@ const UploadExperimentPostSchema = ({
5656
region: z.string().min(1, '').nullable(),
5757
// 지역구
5858
area: z.string().min(1, '').nullable(),
59-
// 상세 주소
60-
detailedAddress: isOnCampus // 교내실험이면 옵셔널, 교내실험이 아니라면 필수값
61-
? z.string().max(70, { message: '최대 70자 이하로 입력해 주세요' }).optional()
62-
: z.string().min(1, '').max(70, { message: '최대 70자 이하로 입력해 주세요' }),
59+
// 상세 주소. 비대면 또는 교내실험이면 옵셔널, 교내실험이 아니라면 필수값.
60+
detailedAddress: z
61+
.string()
62+
.nullable()
63+
.refine(
64+
(val) => {
65+
if (val === null) return true; // 비대면
66+
if (val.length > 70) return false; // 최대 70자 이하
67+
if (!isOnCampus && val.trim().length === 0) return false; // 교내실험이 아니면 필수값
68+
69+
return true;
70+
},
71+
{ message: '최대 70자 이하로 입력해 주세요' },
72+
),
6373

6474
// 보상
6575
reward: z

0 commit comments

Comments
 (0)