-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isFieldValid not working as expected if prevalidate is false #76
Comments
Calling I'm not sure if we have a way to trigger validations only for a specific field. |
Thank you for the clarification there. It would be worth documenting the behaviour in the readme then perhaps as you'll likely get new users asking this same question anyway. My JS/TS foo is much weaker than my C# but in the event, there was some interest from my side in possibly doing a PR for adding the functionality to bypass cache for validation optionally, would that be something meaningful for the library to have? |
I think we should probably add a method to I wonder if it validates the whole form just in case there are dependencies. For example, if an element is only required if another field is valid or something like that. I’m AFK so I can’t look. |
@Maverik can you give this PR a try? #77
I like this as a counterpart to
Validators don't have access to the validation state of other inputs, so dependencies would be on values of other inputs. |
Thank you so much for the quick turn around on this @dahlbyk. I've updated the codepen to use the code from this PR commit 7fe1de0. I can confirm that the new I've also updated the primary input field under testing to test for two validations to ensure multiple validators get exercised as expected in many production scenarios You may use my updated pen as a demo test if you like. You can leave the prevalidate off and just trigger changes in the "Required Field". I've updated the sample to reflect the new callback as well as the old callback. Should you push another commit during your test, you can easily call the new commit from pen by updating the git hash in import url. I'm happy to update the pen once this PR is final if any changes are needed for future readers. Again, thank you very much for the quick turn around. It's highly appreciated! |
Sorry, I'm not sure what you mean by this? Are you referring to a mismatch between the return value and the value passed to the callback? |
Indeed. From my testing, PS: I noticed you updated to a new commit, I've updated pen to pull in latest commit from branch directly now so it's always reflecting your latest work at the point of testing this issue. |
Thank you for figuring that out. I guess this sorts my use-case out. I might have to come back later, when I circle back to that story I was working on but for now, I think this covers all the bases and I can configure the debounce if i need to. |
Hi there,
First of all, thank you for taking on the maintenance role of the library after Ryan. I've just started using the library so if I'm doing something wrong, please point me in the right direction.
Otherwise I've created a codepen repo with the problem and this is essentially the same problem as #28 I believe.
When I try to validate a specific field with prevalidate set to false in order to trigger an API call, the callback is never triggered and the result of isFieldValid appears to lag behind by one call.
i.e. if the last 7 results were false:
I hope you can see now what I mean by "lagging behind by one call".
The behaviour only happens with pre-validate set to false as far as I can tell and behaves as expected when working with the entire form. Of course, that leaves a pretty bad impression when the entire form says its required, even though the user hasn't even gotten to rest of the form yet.
The text was updated successfully, but these errors were encountered: