diff --git a/bower.json b/bower.json index b8b64f59..babd3ec7 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "knockout-validation", - "version": "2.0.3", + "version": "2.0.6", "description": "A KnockoutJS Plugin for model and property validation", "main": "dist/knockout.validation.js", "license": "MIT", @@ -20,7 +20,7 @@ "homepage": "https://github.com/Knockout-Contrib/Knockout-Validation", "repository": { "type": "git", - "url": "git://github.com/Knockout-Contrib/Knockout-Validation.git" + "url": "git://github.com/EikosPartners/Knockout-Validation.git" }, "dependencies": { "knockout": ">=2.3.0" diff --git a/dist/knockout.validation.js b/dist/knockout.validation.js index 07b697b6..3d68fe25 100644 --- a/dist/knockout.validation.js +++ b/dist/knockout.validation.js @@ -512,6 +512,7 @@ kv.configuration = configuration; // 1. Just the params to be passed to the validator // 2. An object containing the Message to be used and the Params to pass to the validator // 3. A condition when the validation rule to be applied + // 4. An object containing the severity to be used // // Example: // var test = ko.observable(3).extend({ @@ -524,17 +525,19 @@ kv.configuration = configuration; // } // )}; // - if (params && (params.message || params.onlyIf)) { //if it has a message or condition object, then its an object literal to use + if (params && (params.message || params.onlyIf || (params.severity && !ko.isObservable(params.severity)))) { //if it has a message, condition, or severity object, then its an object literal to use return kv.addRule(observable, { rule: ruleName, message: params.message, params: utils.isEmptyVal(params.params) ? true : params.params, + severity: params.severity || 1, condition: params.onlyIf }); } else { return kv.addRule(observable, { rule: ruleName, - params: params + params: params, + severity: 1 }); } }; @@ -1204,12 +1207,13 @@ ko.extenders['validatable'] = function (observable, options) { throttleEvaluation : options.throttle || config.throttle }; - observable.error = ko.observable(null); // holds the error message, we only need one since we stop processing validators when one is invalid - + observable.error = ko.observable(null); // holds the error message, we only need one since we stop processing validators when one is invalid and has a severity of 1 + observable.severity = ko.observable(1); + // observable.rules: // ObservableArray of Rule Contexts, where a Rule Context is simply the name of a rule and the params to supply to it // - // Rule Context = { rule: '', params: '', message: '' } + // Rule Context = { rule: '', params: '', message: '', severity: '', params: '', message: '' } + // Rule Context = { rule: '', params: '', message: '', severity: '