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.

Field validation not triggered after reset

See original GitHub issue

Very easy to reproduce:

https://codesandbox.io/s/o22j1lOZB

Modify age, then reset, then modify age, then submit. Field validation on Username and Email are bypassed. UPDATE_SYNC_ERRORS is not triggered after reset like it is when a validated field is dirty.

It looks like the conditions updateSyncErrorsIfNeeded are incorrects.

This is a major issue IMO. I have no easy workaround. @erikras I know you must be terribly busy but can you have a look?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

8reactions
arman-mukatovcommented, Jun 13, 2017

I confirm, the problem is not solved yet, after the reset, verification is not carried out…

p.s. v6.8.0

1reaction
h0wXDcommented, Apr 16, 2018

Same problem happening here. We have an edit mode and read only mode and have an issue with resetting the form. We have two different behaviors happening Behavior 1 (CORRECT): Enter edit mode, update any form value, leave edit mode (reset() is called). formSyncErrors contains all errors of the wrong fields. Behavior 2 (WRONG): Enter edit mode, don’t update any form value, leave edit mode (reset() is called). formSyncErrors contains no fields, but before reset call it did, so it’s being reset somewhere.

for now we found a workaround: //reset(); initialize(originalData);

This is working, since initialize will trigger the validation UPDATE_SYNC_ERRORS message.

p.s. may require enableReinitialize: true, keepDirtyOnReinitialize: true

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validation not working after clear the form - Stack Overflow
After resetting the form you are running validations manually by calling setErrors(null). setErrors(null) means you are setting the form ...
Read more >
Reactive Form - Reset input validation after change
I believe the reason your Form wasn't resetting was because of the 'Built-In Validations' Property of your Delete button. When set to 'Built-In...
Read more >
NgForm - Angular
Method called when the "reset" event is triggered on the form. onReset(): void. Parameters.
Read more >
useForm - reset - React Hook Form
For controlled components you will need to pass defaultValues to useForm in order to reset the Controller components' value. When defaultValues is not...
Read more >
Handling Forms - VeeValidate
In case you want to perform some logic after a form fails to submit due to validation errors (e.g: focusing the first invalid...
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