You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the parseInputAttributes and writeInputAttributes options are set to true; the writeInputAttributes occurs first; then the parseInputAttributes comes along after and says hey, there's some input attributes that i should go create rules for - even though we already have the rule.
Modify addRule() function to check the rule isn't there already. Something like:
addRule: function(observable,rule){if(!utils.isValidatable(observable))observable.extend({validatable: true});varhasRule;ko.utils.arrayForEach(observable.rules(),function(arrRule){if(arrRule.name==rule.name){hasRule=true;return;}});if(!hasRule){//push a Rule Context to the observables local array of Rule Contextsobservable.rules.push(rule);}returnobservable;},
The text was updated successfully, but these errors were encountered:
The rule will not be added if it already exists. This will apply only to rules that have a name.
varobsv=ko.observable(1).extend({min: 10});// obsv.rules().length is 1obsv.extend({min: 20});// The rule will NOT be added because it already exists// obsv.rules().length is still 1
For the upcoming releases we might consider #441 - preferably avoiding breaking changes.
Hm, actually this change is breaking change for me. I need a possibility to set a rule with the same name at least twice in some cases (although rule name is the same, parameters are different). I even created a bug #618. Can be this issue fixed in a different way?
When the parseInputAttributes and writeInputAttributes options are set to true; the writeInputAttributes occurs first; then the parseInputAttributes comes along after and says hey, there's some input attributes that i should go create rules for - even though we already have the rule.
See fiddle for verification:
http://jsfiddle.net/t2y5F/
Suggestion:
Modify addRule() function to check the rule isn't there already. Something like:
The text was updated successfully, but these errors were encountered: