Mini-ghost/vorms

Can't validate boolean value in the example "Validate With Zod"

howard-tzw opened this issue · 2 comments

Describe the bug

Hi

I tried to modify the schema of Zod in the example as follows, but it doesn't prevent users from submitting the form. Not sure if the problem comes from vorms or zod..

 z.object({
      account: z.string().min(1, 'Account is required!'),
      password: z.string().min(1, 'Password is required!'),
      remember: z.boolean(),
    })

Cheers

Reproduction

https://vorms.mini-ghost.dev/examples/#validate-with-zod

Steps to reproduce

Use the following schema:

z.object({
    account: z.string().min(1, 'Account is required!'),
    password: z.string().min(1, 'Password is required!'),
    remember: z.boolean(),
  })

I'm not sure if you want to verify whether the 'remember' field has been checked. This example might solve your needs. If it's not what you're looking for, please provide a more detailed description. Thank you.

https://stackblitz.com/edit/vorms-validate-with-zod-k6qzzg?file=src%2FApp.vue

Regarding how to verify a specific value for 'zod', you can refer to this issue.
👉 colinhacks/zod#220 (comment)

@Mini-ghost Ah, yes. That's what I want. Thanks
Just diving into form development with vorms + zod. Thanks for this nice work!