Giter Club home page Giter Club logo

Comments (7)

sendyputra avatar sendyputra commented on September 15, 2024 1

try assign validate to formik validate={toFormikValidate(Schema)} and its work

Screen Shot 2023-09-12 at 16 50 02 Screen Shot 2023-09-12 at 16 54 05 Screen Shot 2023-09-12 at 16 51 51

from zod-formik-adapter.

iest avatar iest commented on September 15, 2024

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.

robertLichtnow avatar robertLichtnow commented on September 15, 2024

@iest can you add which versions of Zod and Formik you were using when testing?

from zod-formik-adapter.

iest avatar iest commented on September 15, 2024

@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.

alexkuc avatar alexkuc commented on September 15, 2024

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.

alexkuc avatar alexkuc commented on September 15, 2024

Another observation I noticed today. If you define .refine() on schema itself, not individual field, it is also ignored.

from zod-formik-adapter.

veksen avatar veksen commented on September 15, 2024

Is there a workaround people are using for this? I'd specifically like to do password confirmation

from zod-formik-adapter.

Related Issues (10)

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.