Skip to content

Commit 33ddb30

Browse files
authored
ENGCOM-4546: #21734 Error in JS validation rule #21776
2 parents 586b519 + 607189f commit 33ddb30

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

app/code/Magento/Catalog/etc/adminhtml/system.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<field id="grid_per_page_values" translate="label comment" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
6060
<label>Products per Page on Grid Allowed Values</label>
6161
<comment>Comma-separated.</comment>
62-
<validate>validate-per-page-value-list</validate>
62+
<validate>validate-per-page-value-list required-entry</validate>
6363
</field>
6464
<field id="grid_per_page" translate="label comment" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
6565
<label>Products per Page on Grid Default Value</label>
@@ -69,7 +69,7 @@
6969
<field id="list_per_page_values" translate="label comment" type="text" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
7070
<label>Products per Page on List Allowed Values</label>
7171
<comment>Comma-separated.</comment>
72-
<validate>validate-per-page-value-list</validate>
72+
<validate>validate-per-page-value-list required-entry</validate>
7373
</field>
7474
<field id="list_per_page" translate="label comment" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
7575
<label>Products per Page on List Default Value</label>

app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -920,12 +920,12 @@ define([
920920
],
921921
'validate-per-page-value-list': [
922922
function (value) {
923-
var isValid = utils.isEmpty(value),
923+
var isValid = true,
924924
values = value.split(','),
925925
i;
926926

927-
if (isValid) {
928-
return true;
927+
if (utils.isEmpty(value)) {
928+
return isValid;
929929
}
930930

931931
for (i = 0; i < values.length; i++) {

lib/web/mage/validation.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,10 +1431,14 @@
14311431
],
14321432
'validate-per-page-value-list': [
14331433
function (v) {
1434-
var isValid = !$.mage.isEmpty(v),
1434+
var isValid = true,
14351435
values = v.split(','),
14361436
i;
14371437

1438+
if ($.mage.isEmpty(v)) {
1439+
return isValid;
1440+
}
1441+
14381442
for (i = 0; i < values.length; i++) {
14391443
if (!/^[0-9]+$/.test(values[i])) {
14401444
isValid = false;

0 commit comments

Comments
 (0)