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.

Using validationSchema returns empty errors object

See original GitHub issue

🐛 Bug report

Current Behavior

I threw together a quick codesandbox to prototype a concept, and my Yup-based validationSchema always resulted in an empty errors object on submit.

I jumped into the official Formik codesandbox playground and realized the same thing was happening:

formik-validation-schema

Expected behavior

I would have expected { errors: { email: 'Required' } } but perhaps I’m missing something.

Your environment

Software Version(s)
Formik 1.2.0
React 16.5.0
Yup 0.26.3 (0.26.6 on my sandbox)
TypeScript
Browser Firefox, 63.0.3
npm/Yarn
Operating System

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:25
  • Comments:32 (6 by maintainers)

github_iconTop GitHub Comments

10reactions
iRule95commented, Feb 22, 2019

@jaredpalmer this still seems to be an issue. Upgrading to the latest version of formik in the sandbox example doesn’t seem to help either 😕

7reactions
pierrebivercommented, Apr 7, 2019

I set initialValues with default values on my object but it is not working for me neither. I use

    "formik": "^1.5.2",
    "react": "^16.8.6",
    "yup": "^0.27.0"

any news on this issue @jaredpalmer ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Formik errors object is not being updated properly on input
Formik is already handling field change and field blur with the handleChange and handleBlur handlers so it is already making validation checks.
Read more >
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 >
Easy Error Handling and Data Validation with Yup - Code Daily
Our Formik values are in the shape of an object . ... Formik knows how to map the errors returned from yup to...
Read more >
17.7.0 API Reference - joi.dev
Validates a value against a schema, returns valid object, and throws if validation fails where: value - the value to validate. schema -...
Read more >
How to use Yup context variables in Formik validation
... return errors; }, {}); } return {}; } });. Formik natively supports Yup validation objects, which are passed in as validationSchema, or...
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