question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can "validate" and "validateSchema" be used concurrently?

See original GitHub issue

Bug, Feature, or Question?

Question

Current Behavior

Using the withFormik as a HOC, with both a validate function and a validateSchema function, seems to result in only validate being called on a handleSubmit, whereas onBlur events trigger validateSchema.

Desired Behavior

I’m not quite sure here. 😃 Should both validation types be called upon handleSubmit? I imagine if the answer is “yes”, either the results of the errors created by each one would have to be merged (could be messy), or the first one that produces errors stops the other function from being called.

Suggested Solutions

I had both validation types because I had not yet figured out how to handle a few use cases in yup. I think this is a good time to hunker down and figure that out so I only have validationSchema. 😃

If both validation types concurrently are not supported, it should be documented, or at least have the library throw an error if it sees both defined in the withFormik call.

Info

  • Formik Version: 0.11.4
  • OS: OS X Sierra
  • Node Version: 8.9.4
  • Package Manager and version: 5.6.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

61reactions
iwarshakcommented, Feb 27, 2018

Yup is really nice (as is formik), but I have run into validation situations where it’d be nice to be able to use validateSchema as well as a custom validation function.

5reactions
jaredpalmercommented, Mar 29, 2018

I would rather not have to call 2 functions. You can just run Yup validation schema.validate on your own within validate and keep a single source of truth in regards to validation. Imho much better

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validation - Formik
Formik is designed to manage forms with complex validation with ease. Formik supports synchronous and asynchronous form-level and field-level validation.
Read more >
Formik & yup form validation not working as expected with ...
My component is working and I am able to select an option, but why formik together with 'yup' validation showing me an error...
Read more >
Schema Validation with Yup and Express.js
Today I am going to teach you how to make a validation system using Yup together with Express.js. In the past I had...
Read more >
How To Use Schema Validation in MongoDB - DigitalOcean
Run the following insertOne() method to simultaneously create a collection named peaks in your MongoDB installation and insert the previous ...
Read more >
Get started with validation in Node.js - Simon Plenderleith
The first step in putting together request validation for your Node.js ... To validate data against a schema, we need to use a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found