-
Notifications
You must be signed in to change notification settings - Fork 379
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
validatedObservable bug when the initial value is undefined #442
Comments
I think the problem still persists if undefined (or null) is passed as the intial value (common case if you initialize your viewmodel, but fill it with date asynchronously). The code: ko.validatedObservable = function (initialValue, options) {
if (!options && !kv.utils.isObject(initialValue)) {
return ko.observable(initialValue).extend({ validatable: true });
}
[...] returns before it subscribes to the observable and therefore ko.validation.group is never called on the object after it is updated. Which means the content of the validatedObservable is never validated if only it was initialized with undefined once. On the other side... just pass anything (ex. true) in options and the issue is gone.. |
@mikocot See the following tests for more clarification https://github.com/Knockout-Contrib/Knockout-Validation/blob/2.0.3/test/api-tests.js#L714-L744 |
When the initial value of the validatedObservable is undefined, an observable is created with the validated property set to true. This is a problem, because one would expect the validatedObservable to be enabled when setting a future object.
The text was updated successfully, but these errors were encountered: