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

Do not change original data by kv.group #465

Merged
merged 1 commit into from
Nov 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,7 @@
});
};

obj.errors = result;
obj.isValid = function () {
return obj.errors().length === 0;
};
obj.isAnyMessageShown = function () {
result.isAnyMessageShown = function () {
var invalidAndModifiedPresent = false;

// ensure we have latest changes
Expand Down
2 changes: 1 addition & 1 deletion Src/ko.extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ko.validatedObservable = function (initialValue, options) {

var obsv = ko.observable(initialValue);
obsv.errors = ko.validation.group(initialValue, options);
obsv.isValid = ko.observable(initialValue.isValid());
obsv.isValid = ko.observable(obsv.errors().length === 0);


if (ko.isObservable(obsv.errors)) {
Expand Down
6 changes: 3 additions & 3 deletions Tests/api-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ test('validatedObservable does not show error message when not modified', functi
});

ok(obj(), 'observable works');
ok(!obj().isAnyMessageShown(), 'validation error message is hidden');
ok(!obj.errors.isAnyMessageShown(), 'validation error message is hidden');

});

Expand All @@ -288,7 +288,7 @@ test('validatedObservable does not show error message when modified but correct'
obj().testObj2('a');

ok(obj(), 'observable works');
ok(!obj().isAnyMessageShown(), 'validation error message is hidden');
ok(!obj.errors.isAnyMessageShown(), 'validation error message is hidden');

});

Expand All @@ -301,7 +301,7 @@ test('validatedObservable show error message when at least one invalid and modif
obj().testObj.isModified(true);

ok(obj(), 'observable works');
ok(obj().isAnyMessageShown(), 'validation error message is shown');
ok(obj.errors.isAnyMessageShown(), 'validation error message is shown');

});

Expand Down