knockout.js - Aggregate multiple max KO extend validations -


i using ko extend validation validate, trying follows. ko.extend not support multiple bindings same type (max in case) , adds first rule. there way conditionally pass params function? or way out writing custom validation?

         mymodel.prop2.extend({             max: {                 onlyif: function () {                      var test = mymodel.prop1() != undefined &&                         mymodel.prop1() !== "percentage";                     return test;                 },                 params: 100000             }         }).extend({             max: {                 onlyif: function() {                     return mymodel.prop1() != undefined &&                         mymodel.prop1() === "percentage";                 },                 params: 100             }         }); 

found solution,

.extend({             validation: [{                 validator: function (val, someotherval) {                     if (mymodel.prop1()() !== "percentage") {                         return val < someotherval;                     }                     return true;                 },                 message: "too big!!!!",                 params: 100000             }]         }) 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -