diff --git a/lib/web/mage/validation.js b/lib/web/mage/validation.js index dfa35473176b9..eb9613035fd9c 100644 --- a/lib/web/mage/validation.js +++ b/lib/web/mage/validation.js @@ -204,6 +204,21 @@ return empty === 0; } + /** + * + * @param {float} qty + * @param {float} qtyIncrements + * @returns {float} + */ + function resolveModulo(qty, qtyIncrements) { + while (qtyIncrements < 1) { + qty *= 10; + qtyIncrements *= 10; + } + + return qty % qtyIncrements; + } + /** * Collection of validation rules including rules from additional-methods.js * @type {Object} @@ -1610,7 +1625,7 @@ isMaxAllowedValid = typeof params.maxAllowed === 'undefined' || qty <= $.mage.parseNumber(params.maxAllowed), isQtyIncrementsValid = typeof params.qtyIncrements === 'undefined' || - qty % $.mage.parseNumber(params.qtyIncrements) === 0; + resolveModulo(qty, $.mage.parseNumber(params.qtyIncrements)) === 0.0; result = qty > 0;