Comments (7)
try assign validate to formik validate={toFormikValidate(Schema)} and its work
from zod-formik-adapter.
I ran into this issue — it actually does work; however the refine
& superRefine
methods don't get called if there are validation errors coming from inside that object
— so only if there are no other errors will the errors from refine/superRefine actually surface.
This is an issue with how Zod works, rather than this library.
Edit: Actually you're right; the errors don't surface at all with this package. I copy-pasted the main index.ts
into my codebase and got it working like I detailed above. Super weird
from zod-formik-adapter.
@iest can you add which versions of Zod and Formik you were using when testing?
from zod-formik-adapter.
@robertLichtnow not 100% sure as it's been a few months, but my yarn.lock says formik: ^2.2.9
and zod: ^3.19.1
from zod-formik-adapter.
I observed the same behaviour and noticed the following… In my case, I have custom input control driven by Formik's useField()
hook. It's a custom combobox with ability to specify custom value. Here are my observations where .refine
is defined for all conditions:
- when I specify custom error message via
helpers.setError()
,.refine()
is ignored - when I specify custom error value via
helpers.setValue()
,.refine
overrides with its own validation - when I specify both,
.refine()
overrides with its own validation - when I specify no custom error message and no custom error value,
.refine()
is ignored
Edit: added 4th bullet point
from zod-formik-adapter.
Another observation I noticed today. If you define .refine()
on schema itself, not individual field, it is also ignored.
from zod-formik-adapter.
Is there a workaround people are using for this? I'd specifically like to do password confirmation
from zod-formik-adapter.
Related Issues (10)
- Request update support for React 18 HOT 8
- API suggestion
- [BUG] - Type instantiation is excessively deep and possibly infinite. HOT 6
- [BUG] Null exception handling
- Support flattened `union` errors
- check using enum does not validate HOT 14
- [BUG] schema with transform has type mismatch
- .array not working HOT 1
- [BUG] Array errors not working
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 zod-formik-adapter.