Comments (2)
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.
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 zod
s refine
anyway.
from vee-validate.
Related Issues (20)
- Unable to change form's initialValues back to empty object with resetForm force: true HOT 1
- Optional from valibot not working in vee-validate
- v-model value not get updated in parent component HOT 5
- in Production error context not accessible in shared components across nuxt modules or layers
- Adding Vine support for schema validation HOT 1
- Order of `useForm` and `useIsFormValid` HOT 1
- zod catch casts to 'unknown' in toTypedSchema HOT 1
- Add an exemple for daisyUI HOT 1
- The meta.dirty value always true when you use initialValues parameter in useForm()
- make validateOnBlur work with Form and useField and yup schema HOT 1
- Can't enter valid decimal value
- client site validation with inertia (laravel)
- Calling `resetForm()` on a multi-step form does not reset the form.
- Checkbox validation gets called twice
- Typo in .et translation of vee-validate .et locale
- v-model on <Field> does not work in "@vue/compat" mode (vue 3.x, vee: 4.x) HOT 1
- Configure and validateOnBlur not working with primeVue HOT 2
- useResetForm should take an optional second parameter of ResetFormOpts
- `.label()` method is not available with zod
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vee-validate.