Skip to content
Discussion options

You must be logged in to vote

Aha, I figured it out:

you need to set the constraint on the useForm hook.

for me, that looked like:


  const [form, fields] = useForm({
    // Sync the result of last submission
    lastResult,
    constraint: getZodConstraint(FormSchema),
    // Reuse the validation logic on the client
    onValidate({ formData }) {
      return parseWithZod(formData, { schema: FormSchema })
    },

    // Validate the form on blur event triggered
    shouldValidate: 'onBlur',
  })

Hope this helps anyone else curious about this!

I'm also curious as to why this is an option vs just the default behaviour? I can't imagine not wanting this behaviour 🤔

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@andrewcheongprestige
Comment options

Answer selected by DKeen0123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants