You need to change your mapping of SumOfValues to create a computed value rather than an observable value. Here is an updated fiddle that does this:
and the code:
var json = {
"ValueA": 9,
"ValueB": 1,
"SumOfValues": 0
};
function myViewModel(data) {
var self = this;
var mapping = {
'SumOfValues': {
create: function (options) {
return ko.computed( function() {
return (parseInt( self.ValueA() ) + parseInt( self.ValueB() ) );
});
}
}
};
ko.mapping.fromJS(data, mapping, self);
self.isValid = ko.computed(function () {
return (self.SumOfValues() == self.ValueA() + self.ValueB() ? "equal" : "not equal");
});
}
ko.applyBindings(new myViewModel(json));