Skip to content

Commit dce4b70

Browse files
committed
Merge remote-tracking branch 'github-magento2ce/MAGETWO-91657' into EPAM-PR-18
2 parents ad0bd87 + 78e8059 commit dce4b70

File tree

2 files changed

+25
-4
lines changed
  • app/code/Magento

2 files changed

+25
-4
lines changed

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(
4545
}
4646

4747
/**
48-
* {@inheritdoc}
48+
* @inheritdoc
4949
* @since 101.1.0
5050
*/
5151
public function modifyData(array $data)
@@ -54,8 +54,11 @@ public function modifyData(array $data)
5454
}
5555

5656
/**
57-
* {@inheritdoc}
57+
* Add tier price info to meta array.
58+
*
5859
* @since 101.1.0
60+
* @param array $meta
61+
* @return array
5962
*/
6063
public function modifyMeta(array $meta)
6164
{
@@ -150,8 +153,8 @@ private function getUpdatedTierPriceStructure(array $priceMeta)
150153
'dataType' => Price::NAME,
151154
'addbefore' => '%',
152155
'validation' => [
153-
'validate-number' => true,
154-
'less-than-equals-to' => 100
156+
'required-entry' => true,
157+
'validate-positive-percent-decimal' => true
155158
],
156159
'visible' => $firstOption
157160
&& $firstOption['value'] == ProductPriceOptionsInterface::VALUE_PERCENT,

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,24 @@ define([
692692
},
693693
$.mage.__('The value is not within the specified range.')
694694
],
695+
'validate-positive-percent-decimal': [
696+
function (value) {
697+
var numValue;
698+
699+
if (utils.isEmptyNoTrim(value) || !/^\s*-?\d*(\.\d*)?\s*$/.test(value)) {
700+
return false;
701+
}
702+
703+
numValue = utils.parseNumber(value);
704+
705+
if (isNaN(numValue)) {
706+
return false;
707+
}
708+
709+
return utils.isBetween(numValue, 0.01, 100);
710+
},
711+
$.mage.__('Please enter a valid percentage discount value greater than 0.')
712+
],
695713
'validate-digits': [
696714
function (value) {
697715
return utils.isEmptyNoTrim(value) || !/[^\d]/.test(value);

0 commit comments

Comments
 (0)