File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
app/code/Magento/OfflineShipping/view/frontend/web/js/model
shipping-rates-validation-rules Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ define(
18
18
} ,
19
19
'region_id' : {
20
20
'required' : true
21
+ } ,
22
+ 'region_id_input' : {
23
+ 'required' : true
21
24
}
22
25
} ;
23
26
}
Original file line number Diff line number Diff line change @@ -11,16 +11,22 @@ define(
11
11
'mage/translate'
12
12
] ,
13
13
function ( $ , utils , validationRules , $t ) {
14
- " use strict" ;
14
+ ' use strict' ;
15
15
return {
16
16
validationErrors : [ ] ,
17
- validate : function ( address ) {
17
+ validate : function ( address ) {
18
18
var self = this ;
19
19
this . validationErrors = [ ] ;
20
- $ . each ( validationRules . getRules ( ) , function ( field , rule ) {
20
+ $ . each ( validationRules . getRules ( ) , function ( field , rule ) {
21
21
if ( rule . required && utils . isEmpty ( address [ field ] ) ) {
22
22
var message = $t ( 'Field ' ) + field + $t ( ' is required.' ) ;
23
- self . validationErrors . push ( message ) ;
23
+ var regionFields = [ 'region' , 'region_id' , 'region_id_input' ] ;
24
+ if (
25
+ $ . inArray ( field , regionFields ) === - 1
26
+ || utils . isEmpty ( address [ 'region' ] ) && utils . isEmpty ( address [ 'region_id' ] )
27
+ ) {
28
+ self . validationErrors . push ( message ) ;
29
+ }
24
30
}
25
31
} ) ;
26
32
return ! Boolean ( this . validationErrors . length ) ;
You can’t perform that action at this time.
0 commit comments