Giter VIP home page Giter VIP logo

Comments (2)

logaretm avatar logaretm commented on June 16, 2024

It doesn't make sense to show any errors for invalid literals in the UI

In your case maybe, however vee-validate cannot make that assumption. It is up to you to make a Zod schema that can parse the form values in order for it to become valid. vee-validate is in no position to decide which errors to ignore and which to keep.

I use refines most of the time as unions tend to be a hit or miss due to it not exactly expressing the form nature of the values and Zod being TypeScript influenced.

I use yup since it has better error messages and overall feels suitable to forms more than Zod to be honest. I don't think this is a bug vee-validate should fix.

from vee-validate.

xak2000 avatar xak2000 commented on June 16, 2024

In your case maybe, however vee-validate cannot make that assumption.

I can't imageine a case when you need more than 1 error for a union of literals. Union of literals literally means that the value should be one of X, Y, Z. It doesn't make sense to have a separate error message for each literal. Even if value is not X, it could still be Y or Z. So, literal X should not generate error if value is not X. Because it is a union after all.

But this is another topic, of course. I would rather call it a problem of zod, not VeeValidate.

I also don't think it is a bug of vee-validte. Rather, it is usability problem caused by mismatch of concepts. In current state a zod schema, that represents union of literals is basically unusable with vee-validate.

Thank you for the response! I will stick with refine for now. Also I quickly researched how this problem could be solved with yup and found out that yup doesn't support unions at all. So, probably migrating to yup will not help as the solution will be similar to zods refine anyway.

from vee-validate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.