Implement observable.error as an observable and not as a plain string variable
I've spent five hours yesterday chasing down a bug similar to #47 ('required' message was displayed instead of the expected custom validators message). No I have not yet managed to reproduce this bug in a jsFiddle, but during my debugging sessions i noticed that the .error property of the validated observable contained the correct message, while the message inserted on the screen was wrong.
To me this seemed like a timing issue (insertMessage handler seems to be called miliseconds BEFORE error message gets updated correctly)
I wondered why observable.error is just a plain string variable instead of an observable... If the insertMessage handler referenced this observable, it could update the error message even it was changed after the creation of the error insert.
@fbuchinger I had a similar problem previously - see PR 105 (https://github.com/ericmbarnard/Knockout-Validation/pull/105). Unfortunately I've been unable to pinpoint the root cause (it was a while ago but I believe I also came to the conclusion that it was timing-related).
In my scenario making observable.error an observable has made the problem go away, but I haven't chased up on the PR because I wasn't sure how widespread this bug was and I don't know whether there are implications I'm not aware of (performance, etc.?) in making the error property observable.
@TerenceLewis Thanks for this wonderful patch! Seems to solve my issues :) I'm still a bit cautious, because as we both know this bug is quite unpredictable and non-reproduceable. But my validation will undergo heavy testing in the next days and I will notify you and Eric once the patch has survived more extensive tests.
@TerenceLewis @ericmbarnard : Terence's patch worked for us even in rigid testing. I can only recommend to merge it into knockout-validation.
@TerenceLewis @ericmbarnard : This patch fixed a similar issue for me. Looking forward to a merge. Thanks guys.
Fixed by #248