Skip to content

Commit 0774d8e

Browse files
committed
Update knockout.validation 1.0.2 to the NuGet package version
The GitHub v1.0.2 tag is a lot older, and didn't work for some of my scenarios
1 parent 5e79b70 commit 0774d8e

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed
18 Bytes
Binary file not shown.

knockout.validation/knockout.validation_1.0.2/knockout.validation.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

2525
if (typeof (ko) === undefined) { throw 'Knockout is required, please ensure it is loaded before loading this validation plug-in'; }
2626

27-
if (typeof define === "function" && define["amd"]) {
28-
exports = ko.validation = {};
29-
}
27+
// create our namespace object
28+
var validation = exports;
29+
ko.validation = validation;
3030

3131
var defaults = {
3232
registerExtenders: true,
@@ -146,7 +146,7 @@
146146
//#endregion
147147

148148
//#region Public API
149-
var validation = (function () {
149+
var api = (function () {
150150

151151
var isInitialized = 0;
152152

@@ -453,7 +453,10 @@
453453
contexts = null;
454454
}
455455
};
456-
} ());
456+
}());
457+
458+
// expose api publicly
459+
ko.utils.extend(validation, api);
457460
//#endregion
458461

459462
//#region Core Validation Rules
@@ -532,7 +535,7 @@
532535

533536
validation.rules['pattern'] = {
534537
validator: function (val, regex) {
535-
return utils.isEmptyVal(val) || val.match(regex) != null;
538+
return utils.isEmptyVal(val) || val.toString().match(regex) != null;
536539
},
537540
message: 'Please check this value.'
538541
};
@@ -739,7 +742,7 @@
739742

740743
//toggle visibility on validation messages when validation hasn't been evaluated, or when the object isValid
741744
var visiblityAccessor = function () {
742-
return isModified ? !isValid : false;
745+
return (!config.messagesOnModified || isModified) ? !isValid : false;
743746
};
744747

745748
ko.bindingHandlers.text.update(element, errorMsgAccessor);
@@ -1072,8 +1075,4 @@
10721075
};
10731076

10741077
//#endregion
1075-
1076-
/// apply our public api to the public object
1077-
ko.utils.extend(exports, validation);
1078-
10791078
}));

0 commit comments

Comments
 (0)