Skip to content

Commit

Permalink
Merge pull request #465 from khakulov/kv-group-fix
Browse files Browse the repository at this point in the history
Do not change original data by kv.group
  • Loading branch information
crissdev committed Nov 24, 2014
2 parents 2485d73 + 2dada74 commit c12e739
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
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

0 comments on commit c12e739

Please sign in to comment.