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)
- d HOT 1
- useFieldParam HOT 1
- [docs]: Codepen on the Validation page does not work HOT 1
- 4.12.7 broke zod validation HOT 2
- Not assignable to parameter of type 'ZodType<any, ZodTypeDef, any>' error on toTypedSchema HOT 1
- Dynamic custom checkbox and dynamic input value update issue - Composition API
- Trying to set a custom error message using setFieldError against a Field HOT 1
- Custom input not working with yup.ref() HOT 1
- Allow resetField() to set (or keep) the "initialValue" associated to a field HOT 6
- `@vee-validate/valibot` not yet compatible with Valibot 0.31.0 HOT 1
- Checkbox not working in dynamic loop
- Mix of Nested objects and Avoiding nesting HOT 1
- Unable to set a default value on a checkbox field HOT 3
- Registering @vee-validate/rules in typescript produces typing errors HOT 1
- Type Error `errorBag` using array in form
- Use conditional Validation Schema HOT 2
- touched from useField not triggered after touch field HOT 1
- Custom Localization Files
- validateField can't access nested properties
- Unable to setFieldError from API with multi-step form wizard in before step
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.