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

async Validation doesn't support caching of responses #341

Closed
fbuchinger opened this issue Oct 22, 2013 · 5 comments
Closed

async Validation doesn't support caching of responses #341

fbuchinger opened this issue Oct 22, 2013 · 5 comments
Labels
Milestone

Comments

@fbuchinger
Copy link

async validation seems to have problems when a caching mechanism is implemented in the validation handler (use case: prevent unnecessary server requests for repeated inputs). the validation message isn't shown when the remote validation message comes from the cache and not from the async request.

demo:
http://jsfiddle.net/fbuchinger/KVxNN/6/

@fbuchinger
Copy link
Author

Caching seems to work if you invoke the "cached callback" with a zero-timeout:

http://jsfiddle.net/fbuchinger/KVxNN/8/

@jhsowter
Copy link
Contributor

jhsowter commented Feb 6, 2015

Hi

I had the same issue where my validation callback would occur immediately if certain data was already cached. The reason is because "validateObservable" in the knockout-validation source code sets the current "valid" value to true after the async call returns (it expects the async call to return some time later, and set the value correctly then).

Your linked fiddler fixes the issue, but it could be included in the knockout-validation source code. Have you issued a pull request to that effect?

@crissdev crissdev added the bug label Feb 6, 2015
@crissdev crissdev added this to the 2.1.0 milestone Feb 6, 2015
@crissdev
Copy link
Member

crissdev commented Feb 6, 2015

The fix for this seems pretty straightforward. validateAsync should execute async - ko.validation.utils.async. @jhsowter Would you like to submit a PR for this?

Updated fiddle http://jsfiddle.net/mk9bxnLr/

@jhsowter
Copy link
Contributor

jhsowter commented Feb 6, 2015

I'd love to make a PR. Just need time to fork. Probably be done within 24hr.

@crissdev
Copy link
Member

crissdev commented Feb 6, 2015

No need to rush. This is for the 2.1.0 release. Consider writing some unit tests too. If you need any help just leave a comment here. Thanks.
👍

jhsowter added a commit to jhsowter/Knockout-Validation that referenced this issue Feb 8, 2015
@crissdev crissdev modified the milestones: 2.0.3, 2.1.0 May 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants