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't use complex validation with `validateOnMount`

See original GitHub issue

I’m trying to run a complex validation that relies on other form fields using validateOnMount. It appears as though the validate function doesn’t receive the second values argument when validateOnMount is enabled.

https://github.com/joepuzzo/informed/blob/master/src/hooks/useField.js#L270 and https://github.com/joepuzzo/informed/blob/master/src/hooks/useField.js#L559

Compare that with the asyncValidateOnMount implementation which does appear to receive the values argument - https://github.com/joepuzzo/informed/blob/master/src/hooks/useField.js#L351

A simple reproduction - https://codesandbox.io/s/proud-framework-9txxg?file=/src/MyForm.js

If the solution is as simple as what I’ve laid out, I’m happy to submit a PR with the change, I’m just unsure of any unintended side effects it may cause.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
joepuzzocommented, Dec 13, 2021

V4 is out! Go check it out

0reactions
joepuzzocommented, Nov 4, 2021

Ok I have solve in V4

Read more comments on GitHub >

github_iconTop Results From Across the Web

validateOnMount: Initial value for is valid should be whether ...
The example is a simplification - application code has a far more complex validation schema + more initial values. Your environment. Software ...
Read more >
How to trigger validation in formik after rendering?
I made a basic demo version using a custom input component. ... and bypass the logic that won't show validations if the form's...
Read more >
Validation - VeeValidate
vee-validate handles complex validations in a very easy way, ... A Field component represents a single form input and can be used to...
Read more >
API Reference - Formik
If you are using validate , then that function will determine the errors objects ... object that you can use to represent form...
Read more >
useForm - trigger - Simple React forms validation
Should focus the input during setting an error. This only works when the input's reference is registered, it will not work for custom...
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