//Allows us to pass an observable regex
ko.validation.rules['ko_pattern'] = {
validator: function (val, regex) {
return ko.validation.utils.isEmptyVal(val) || val.match(regex()) != null;
},
message: 'Please check this value.'
}
FYI regex is an ko observable.