Skip to content

Commit

Permalink
ENGCOM-4610: [Backport] #21734 Error in JS validation rule #21813
Browse files Browse the repository at this point in the history
  • Loading branch information
sivaschenko authored Apr 4, 2019
2 parents 413332e + e169f4d commit 48ecf4f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/code/Magento/Catalog/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<field id="grid_per_page_values" translate="label comment" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Products per Page on Grid Allowed Values</label>
<comment>Comma-separated.</comment>
<validate>validate-per-page-value-list</validate>
<validate>validate-per-page-value-list required-entry</validate>
</field>
<field id="grid_per_page" translate="label comment" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Products per Page on Grid Default Value</label>
Expand All @@ -66,7 +66,7 @@
<field id="list_per_page_values" translate="label comment" type="text" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Products per Page on List Allowed Values</label>
<comment>Comma-separated.</comment>
<validate>validate-per-page-value-list</validate>
<validate>validate-per-page-value-list required-entry</validate>
</field>
<field id="list_per_page" translate="label comment" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Products per Page on List Default Value</label>
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,12 +919,12 @@ define([
],
'validate-per-page-value-list': [
function (value) {
var isValid = utils.isEmpty(value),
var isValid = true,
values = value.split(','),
i;

if (isValid) {
return true;
if (utils.isEmpty(value)) {
return isValid;
}

for (i = 0; i < values.length; i++) {
Expand Down
6 changes: 5 additions & 1 deletion lib/web/mage/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1425,10 +1425,14 @@
],
'validate-per-page-value-list': [
function (v) {
var isValid = !$.mage.isEmpty(v),
var isValid = true,
values = v.split(','),
i;

if ($.mage.isEmpty(v)) {
return isValid;
}

for (i = 0; i < values.length; i++) {
if (!/^[0-9]+$/.test(values[i])) {
isValid = false;
Expand Down

0 comments on commit 48ecf4f

Please sign in to comment.