@@ -77,25 +77,36 @@ function StringSchema() {
7777 }
7878 } ) ;
7979 } ,
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 ] ;
8282
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 ;
8590
8691 return this . test ( {
87- message : msg || _locale . string . matches ,
92+ message : message || _locale . string . matches ,
8893 params : { regex : regex } ,
8994 test : function test ( value ) {
9095 return ( 0 , _isAbsent2 . default ) ( value ) || value === '' && excludeEmptyString || regex . test ( value ) ;
9196 }
9297 } ) ;
9398 } ,
9499 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+ } ) ;
96104 } ,
97105 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+ } ) ;
99110 } ,
100111
101112
0 commit comments