Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.label() method is not available with zod #4708

Closed
1 of 5 tasks
madebyfabian opened this issue Mar 21, 2024 · 2 comments
Closed
1 of 5 tasks

.label() method is not available with zod #4708

madebyfabian opened this issue Mar 21, 2024 · 2 comments
Labels
📚 docs documentation related

Comments

@madebyfabian
Copy link

What happened?

Hi there! When I want to use the zod schema declaration to add a custom label to it (with z.string().label('My label')) like in the docs https://vee-validate.logaretm.com/v4/guide/composition-api/custom-inputs#custom-field-labels, it errors:

Property label does not exist on type 'ZodString'

Reproduction steps

  1. Install latest versions of zod@3.22.4, @vee-validate/zod@4.12.6 and vee-validate@4.12.6
  2. Create a schema:
const schema = z.object({
  title: z.string().min(1).label('My label'),
})
  1. Get the type error I listed above + a runtime error (page throws with HTTP 500)

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

No response

Demo link

Can be provided if needed

Code of Conduct

@logaretm
Copy link
Owner

logaretm commented May 28, 2024

Zod doesn't offer this AFAIK, you should instead override their messages. I know its not ideal but Zod is not optimized for forms in particular IMO.

I will update that part of the docs, thanks for creating this issue.

@logaretm logaretm added the 📚 docs documentation related label May 28, 2024
@madebyfabian
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 docs documentation related
Projects
None yet
Development

No branches or pull requests

2 participants