File tree Expand file tree Collapse file tree 3 files changed +33
-2
lines changed
app/code/Magento/Ui/view/base/web/js/lib/validation
dev/tests/js/jasmine/tests/lib/mage Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -235,7 +235,7 @@ define([
235
235
] ,
236
236
'mobileUK' : [
237
237
function ( value ) {
238
- return value . length > 9 && value . match ( / ^ ( ( 0 | \+ 4 4 ) 7 ( 5 | 6 | 7 | 8 | 9 ) { 1 } \d { 2 } \s ? \d { 6 } ) $ / ) ;
238
+ return value . length > 9 && value . match ( / ^ ( ( 0 | \+ 4 4 ) 7 \d { 3 } \s ? \d { 6 } ) $ / ) ;
239
239
} ,
240
240
$ . mage . __ ( 'Please specify a valid mobile number' )
241
241
] ,
Original file line number Diff line number Diff line change @@ -132,4 +132,35 @@ define([
132
132
) . toEqual ( false ) ;
133
133
} ) ;
134
134
} ) ;
135
+
136
+ describe ( 'Testing UK Mobile number validation' , function ( ) {
137
+ it ( 'Valid UK Mobile Number' , function ( ) {
138
+ var element = $ ( '<input id="telephone" type="text" value="07400123456" />' ) ;
139
+
140
+ expect ( $ . validator . methods . mobileUK . call (
141
+ $ . validator . prototype , element . val ( ) , element . get ( 0 )
142
+ ) ) . toBeTruthy ( ) ;
143
+ } ) ;
144
+ it ( 'Invalid UK Mobile Number' , function ( ) {
145
+ var element = $ ( '<input id="telephone" type="text" value="06400123456" />' ) ;
146
+
147
+ expect ( $ . validator . methods . mobileUK . call (
148
+ $ . validator . prototype , element . val ( ) , element . get ( 0 )
149
+ ) ) . toBeFalsy ( ) ;
150
+ } ) ;
151
+ it ( 'Valid UK Mobile Number (International)' , function ( ) {
152
+ var element = $ ( '<input id="telephone" type="text" value="+447400123456" />' ) ;
153
+
154
+ expect ( $ . validator . methods . mobileUK . call (
155
+ $ . validator . prototype , element . val ( ) , element . get ( 0 )
156
+ ) ) . toBeTruthy ( ) ;
157
+ } ) ;
158
+ it ( 'Invalid UK Mobile Number' , function ( ) {
159
+ var element = $ ( '<input id="telephone" type="text" value="+446400123456" />' ) ;
160
+
161
+ expect ( $ . validator . methods . mobileUK . call (
162
+ $ . validator . prototype , element . val ( ) , element . get ( 0 )
163
+ ) ) . toBeFalsy ( ) ;
164
+ } ) ;
165
+ } ) ;
135
166
} ) ;
Original file line number Diff line number Diff line change 384
384
'mobileUK' : [
385
385
function ( phoneNumber , element ) {
386
386
return this . optional ( element ) || phoneNumber . length > 9 &&
387
- phoneNumber . match ( / ^ ( ( 0 | \+ 4 4 ) 7 ( 5 | 6 | 7 | 8 | 9 ) { 1 } \d { 2 } \s ? \d { 6 } ) $ / ) ;
387
+ phoneNumber . match ( / ^ ( ( 0 | \+ 4 4 ) 7 \d { 3 } \s ? \d { 6 } ) $ / ) ;
388
388
} ,
389
389
$ . mage . __ ( 'Please specify a valid mobile number' )
390
390
] ,
You can’t perform that action at this time.
0 commit comments