@@ -77,25 +77,36 @@ function StringSchema() {
77
77
}
78
78
} ) ;
79
79
} ,
80
- matches : function matches ( regex , msg ) {
81
- var _ref = arguments . length <= 2 || arguments [ 2 ] === undefined ? { } : arguments [ 2 ] ;
80
+ matches : function matches ( regex ) {
81
+ var options = arguments . length <= 1 || arguments [ 1 ] === undefined ? { } : arguments [ 1 ] ;
82
82
83
- var _ref$excludeEmptyStri = _ref . excludeEmptyString ;
84
- var excludeEmptyString = _ref$excludeEmptyStri === undefined ? true : _ref$excludeEmptyStri ;
83
+ var excludeEmptyString = false ,
84
+ message = void 0 ;
85
+
86
+ if ( options . message || options . hasOwnProperty ( 'excludeEmptyString' ) ) {
87
+ excludeEmptyString = options . excludeEmptyString ;
88
+ message = options . message ;
89
+ } else message = options ;
85
90
86
91
return this . test ( {
87
- message : msg || _locale . string . matches ,
92
+ message : message || _locale . string . matches ,
88
93
params : { regex : regex } ,
89
94
test : function test ( value ) {
90
95
return ( 0 , _isAbsent2 . default ) ( value ) || value === '' && excludeEmptyString || regex . test ( value ) ;
91
96
}
92
97
} ) ;
93
98
} ,
94
99
email : function email ( msg ) {
95
- return this . matches ( rEmail , msg || _locale . string . email ) ;
100
+ return this . matches ( rEmail , {
101
+ message : msg || _locale . string . email ,
102
+ excludeEmptyString : true
103
+ } ) ;
96
104
} ,
97
105
url : function url ( msg ) {
98
- return this . matches ( rUrl , msg || _locale . string . url ) ;
106
+ return this . matches ( rUrl , {
107
+ message : msg || _locale . string . url ,
108
+ excludeEmptyString : true
109
+ } ) ;
99
110
} ,
100
111
101
112
0 commit comments