NuxtN
Nuxt9mo ago
8 replies
WiFi Plug

nuxt ui form validation, zod, validate only specific field not whole form

Hi I have a nuxt ui form using zod error validation, one of my fields is a cloudflare turnstile token which is validated to ensure it's not empty. however once the error appears if i complete the turnstile challenge the zod error wouldn't disappear until resubmitting the form. so I added a watcher to check when the turnstile token isn't empty to validate the specific field in order to clear the error. however this seemingly triggers my whole form validation.
formRef.value.validate('cfTurnstileToken', { silent: false })
should this work or is there another way to do this? as currently my watcher when i load my form will trigger this on initial load which in turn shows errors on all my inputs that weren't filled in
Was this page helpful?