diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js
index 5f06d26e2acfc..afe22475981ec 100644
--- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js
+++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js
@@ -18,7 +18,6 @@ define(
'Magento_Vault/js/view/payment/vault-enabler',
'Magento_Braintree/js/view/payment/kount',
'mage/translate',
- 'prototype',
'domReady!'
],
function (
diff --git a/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js b/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js
index aca843872af65..55cd77b196be5 100644
--- a/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js
+++ b/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js
@@ -16,7 +16,8 @@ define([
groupedInfo: '#super-product-table input',
downloadableInfo: '#downloadable-links-list input',
customOptionsInfo: '.product-custom-option',
- qtyInfo: '#qty'
+ qtyInfo: '#qty',
+ actionElement: '[data-action="add-to-wishlist"]'
},
/** @inheritdoc */
@@ -30,8 +31,10 @@ define([
_bind: function () {
var options = this.options,
dataUpdateFunc = '_updateWishlistData',
+ validateProductQty = '_validateWishlistQty',
changeCustomOption = 'change ' + options.customOptionsInfo,
changeQty = 'change ' + options.qtyInfo,
+ updateWishlist = 'click ' + options.actionElement,
events = {},
key;
@@ -45,6 +48,7 @@ define([
events[changeCustomOption] = dataUpdateFunc;
events[changeQty] = dataUpdateFunc;
+ events[updateWishlist] = validateProductQty;
for (key in options.productType) {
if (options.productType.hasOwnProperty(key) && options.productType[key] + 'Info' in options) {
@@ -220,6 +224,23 @@ define([
$(form).attr('action', action).submit();
});
+ },
+
+ /**
+ * Validate product quantity before updating Wish List
+ *
+ * @param {jQuery.Event} event
+ * @private
+ */
+ _validateWishlistQty: function (event) {
+ var element = $(this.options.qtyInfo);
+
+ if (!(element.validation() && element.validation('isValid'))) {
+ event.preventDefault();
+ event.stopPropagation();
+
+ return;
+ }
}
});
diff --git a/app/etc/di.xml b/app/etc/di.xml
index 308ec1ef4d6ed..8120676e8dda5 100644
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -167,6 +167,7 @@
+
diff --git a/dev/tests/integration/testsuite/Magento/Framework/DataObject/IdentityValidatorTest.php b/dev/tests/integration/testsuite/Magento/Framework/DataObject/IdentityValidatorTest.php
new file mode 100644
index 0000000000000..15f54ba01a795
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Framework/DataObject/IdentityValidatorTest.php
@@ -0,0 +1,41 @@
+identityValidator = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+ ->get(IdentityValidator::class);
+ }
+
+ public function testIsValid()
+ {
+ $isValid = $this->identityValidator->isValid(self::VALID_UUID);
+ $this->assertEquals(true, $isValid);
+ }
+
+ public function testIsNotValid()
+ {
+ $isValid = $this->identityValidator->isValid(self::INVALID_UUID);
+ $this->assertEquals(false, $isValid);
+ }
+
+ public function testEmptyValue()
+ {
+ $isValid = $this->identityValidator->isValid('');
+ $this->assertEquals(false, $isValid);
+ }
+}
diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.test.js
index 207d14bf990c3..f157ae27ee532 100644
--- a/dev/tests/js/jasmine/tests/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.test.js
+++ b/dev/tests/js/jasmine/tests/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.test.js
@@ -6,15 +6,22 @@
define([
'jquery',
'Magento_Wishlist/js/add-to-wishlist'
-], function ($) {
+], function ($, Widget) {
'use strict';
describe('Testing addToWishlist widget', function () {
- var wdContainer;
+ var wdContainer,
+ wishlistWidget,
+ eventMock = {
+ preventDefault: jasmine.createSpy(),
+ stopPropagation: jasmine.createSpy()
+ };
beforeEach(function () {
wdContainer = $('');
+ wishlistWidget = new Widget();
+ $.fn.validation = {};
});
afterEach(function () {
@@ -31,5 +38,15 @@ define([
});
expect(wdContainer.addToWishlist('option', 'bundleInfo')).toBe('test');
});
+
+ it('verify update wichlist with validate product qty, valid qty', function () {
+ var validation = spyOn($.fn, 'validation').and.returnValue(false);
+
+ wishlistWidget._validateWishlistQty(eventMock);
+ expect(validation).toHaveBeenCalled();
+ expect(eventMock.preventDefault).toHaveBeenCalled();
+ expect(eventMock.stopPropagation).toHaveBeenCalled();
+ });
+
});
});
diff --git a/lib/internal/Magento/Framework/DataObject/IdentityValidator.php b/lib/internal/Magento/Framework/DataObject/IdentityValidator.php
new file mode 100644
index 0000000000000..e8c068a093cb5
--- /dev/null
+++ b/lib/internal/Magento/Framework/DataObject/IdentityValidator.php
@@ -0,0 +1,27 @@
+