RHF - handleSubmit 호출 시에만 유효성 검사 하기 with Zod #684
sunmerrr
started this conversation in
Today I Learned
Replies: 1 comment
-
|
크 RHF 저도 엄청 애용하는 라이브러리입니다ㅎㅎ revalidatemode라는 것도 있어서, 한 번 validation 후 언제 다시 revalidate할지 시점을 선택할때 유용하더라고요 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
내가 의도한 것 - 커스터 마이징이 필요한 유효성 검사를 zod의 superRefine 안으로 몰아두고 submit 할때만 커스텀 유효성 검사하도록 실행
실제 동작 - 값을 바꿀때마다 superRefine 속 커스텀 유효성 검사 실행
superRefine 이 실행되기 위한 조건
내가 생각한 단순 submit 보다 더 많은 경우에 superRefine 이 호출되엇다.
그리고 내 form 에는 trigger 도 있었고, setValue(..., { shouldValidate: true }) 도 있었다.
다 모두 레거시라 다 걷어냈다.
깔끔하게 내가 원하는 타이밍에만 동작한다.
(제발 제대로 알고 쓰자!!!)
Beta Was this translation helpful? Give feedback.
All reactions