Skip to content
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

Inconsistent state while async validation #19

Open
abgenullt opened this issue Apr 3, 2019 · 2 comments
Open

Inconsistent state while async validation #19

abgenullt opened this issue Apr 3, 2019 · 2 comments

Comments

@abgenullt
Copy link

Hi,
at first, thanks for this great library!

But if your UserRegistrationService (In your example) takes, like 1, 2 or more seconds to run, the form is in an false valid or invalid state. The User may edit the username while validating or just press the "submit" button.

Maybe there should be a state object, that you will get by adding a async rule. You could bind to that and disable the text box or do whatever you want. Or the validation state could be set to invalid before execute an async rule.

Regards

abgenullt

@pglazkov
Copy link
Owner

pglazkov commented Apr 9, 2019

Hi abgenullt,

Thanks for taking the time to make this bug report. Indeed, I see the issue. However your suggestion to make the state invalid might not be a good solution because it is an incorrect state and a validation error might be shown to the user while in fact there is no error.

One of the solution that comes to mind would be to block the GetResult call if the state is "unknown" that is while rules are being evaluated. However, simply blocking the thread might possibly lead to deadlocks, so it might not be the best solution. Another alternative would be to make GetResult async and return the result after all rules are executed, but that is a breaking change and I'd prefer to avoid any breaking changes for this.

Anyway, I'll think about it a bit more and probably come up with some solution.

@abgenullt
Copy link
Author

That would be great! I hope you find a good solution.

Thank you for your effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants