File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed
knockout.validation/knockout.validation_1.0.2 Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change 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 ,
146146 //#endregion
147147
148148 //#region Public API
149- var validation = ( function ( ) {
149+ var api = ( function ( ) {
150150
151151 var isInitialized = 0 ;
152152
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
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 } ;
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 ) ;
10721075 } ;
10731076
10741077 //#endregion
1075-
1076- /// apply our public api to the public object
1077- ko . utils . extend ( exports , validation ) ;
1078-
10791078} ) ) ;
You can’t perform that action at this time.
0 commit comments