diff --git a/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php b/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php index 6dab7ca3bdbcf..be3bf46275140 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php @@ -324,93 +324,11 @@ protected function _validateInputRule($value) break; case 'email': /** - __("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded") - __("Invalid type given. String expected") - __("'%value%' appears to be a DNS hostname but contains a dash in an invalid position") - __("'%value%' does not match the expected structure for a DNS hostname") - __("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'") - __("'%value%' does not appear to be a valid local network name") - __("'%value%' does not appear to be a valid URI hostname") - __("'%value%' appears to be an IP address, but IP addresses are not allowed") - __("'%value%' appears to be a local network name but local network names are not allowed") - __("'%value%' appears to be a DNS hostname but cannot extract TLD part") - __("'%value%' appears to be a DNS hostname but cannot match TLD against known list") + __('"%1" is not a valid email address.') */ - $validator = new \Zend_Validate_EmailAddress(); - $validator->setMessage( - __('"%1" invalid type entered.', $label), - \Zend_Validate_EmailAddress::INVALID - ); - $validator->setMessage( - __('"%1" is not a valid email address.', $label), - \Zend_Validate_EmailAddress::INVALID_FORMAT - ); - $validator->setMessage( - __('"%1" is not a valid hostname.', $label), - \Zend_Validate_EmailAddress::INVALID_HOSTNAME - ); - $validator->setMessage( - __('"%1" is not a valid hostname.', $label), - \Zend_Validate_EmailAddress::INVALID_MX_RECORD - ); - $validator->setMessage( - __('"%1" is not a valid hostname.', $label), - \Zend_Validate_EmailAddress::INVALID_MX_RECORD - ); - $validator->setMessage( - __('"%1" is not a valid email address.', $label), - \Zend_Validate_EmailAddress::DOT_ATOM - ); - $validator->setMessage( - __('"%1" is not a valid email address.', $label), - \Zend_Validate_EmailAddress::QUOTED_STRING - ); - $validator->setMessage( - __('"%1" is not a valid email address.', $label), - \Zend_Validate_EmailAddress::INVALID_LOCAL_PART - ); - $validator->setMessage( - __('"%1" uses too many characters.', $label), - \Zend_Validate_EmailAddress::LENGTH_EXCEEDED - ); - $validator->setMessage( - __("'%value%' looks like an IP address, which is not an acceptable format."), - \Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED - ); - $validator->setMessage( - __("'%value%' looks like a DNS hostname but we cannot match the TLD against known list."), - \Zend_Validate_Hostname::UNKNOWN_TLD - ); - $validator->setMessage( - __("'%value%' looks like a DNS hostname but contains a dash in an invalid position."), - \Zend_Validate_Hostname::INVALID_DASH - ); - $validator->setMessage( - __( - "'%value%' looks like a DNS hostname but we cannot match it against the hostname schema for TLD '%tld%'." - ), - \Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA - ); - $validator->setMessage( - __("'%value%' looks like a DNS hostname but cannot extract TLD part."), - \Zend_Validate_Hostname::UNDECIPHERABLE_TLD - ); - $validator->setMessage( - __("'%value%' does not look like a valid local network name."), - \Zend_Validate_Hostname::INVALID_LOCAL_NAME - ); - $validator->setMessage( - __("'%value%' looks like a local network name, which is not an acceptable format."), - \Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED - ); - $validator->setMessage( - __( - "'%value%' appears to be a DNS hostname, but the given punycode notation cannot be decoded." - ), - \Zend_Validate_Hostname::CANNOT_DECODE_PUNYCODE - ); + $validator = new \Magento\Framework\Validator\EmailMinimal(); if (!$validator->isValid($value)) { - return array_unique($validator->getMessages()); + return $validator->getMessages(); } break; case 'url': diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php index 8c142f2eddcb1..46e53c5cf6421 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php @@ -262,7 +262,6 @@ public function validateInputRuleDataProvider() 'email', [ // @codingStandardsIgnoreStart - \Zend_Validate_EmailAddress::INVALID_HOSTNAME => '"mylabel" is not a valid hostname.', \Zend_Validate_Hostname::INVALID_HOSTNAME => "'#\$' does not match the expected structure for a DNS hostname", \Zend_Validate_Hostname::INVALID_LOCAL_NAME => "'#\$' does not look like a valid local network name." // @codingStandardsIgnoreEnd diff --git a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php index d7bea31e6f701..51156aeabe846 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php @@ -353,93 +353,11 @@ protected function _validateInputRule($value) break; case 'email': /** - __("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded") - __("Invalid type given. String expected") - __("'%value%' appears to be a DNS hostname but contains a dash in an invalid position") - __("'%value%' does not match the expected structure for a DNS hostname") - __("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'") - __("'%value%' does not appear to be a valid local network name") - __("'%value%' does not appear to be a valid URI hostname") - __("'%value%' appears to be an IP address but IP addresses are not allowed") - __("'%value%' appears to be a local network name but local network names are not allowed") - __("'%value%' appears to be a DNS hostname but cannot extract TLD part") - __("'%value%' appears to be a DNS hostname but cannot match TLD against known list") - */ - $validator = new \Zend_Validate_EmailAddress(); - $validator->setMessage( - __('"%1" invalid type entered.', $label), - \Zend_Validate_EmailAddress::INVALID - ); - $validator->setMessage( - __('"%1" is not a valid email address.', $label), - \Zend_Validate_EmailAddress::INVALID_FORMAT - ); - $validator->setMessage( - __('"%1" is not a valid hostname.', $label), - \Zend_Validate_EmailAddress::INVALID_HOSTNAME - ); - $validator->setMessage( - __('"%1" is not a valid hostname.', $label), - \Zend_Validate_EmailAddress::INVALID_MX_RECORD - ); - $validator->setMessage( - __('"%1" is not a valid hostname.', $label), - \Zend_Validate_EmailAddress::INVALID_MX_RECORD - ); - $validator->setMessage( - __('"%1" is not a valid email address.', $label), - \Zend_Validate_EmailAddress::DOT_ATOM - ); - $validator->setMessage( - __('"%1" is not a valid email address.', $label), - \Zend_Validate_EmailAddress::QUOTED_STRING - ); - $validator->setMessage( - __('"%1" is not a valid email address.', $label), - \Zend_Validate_EmailAddress::INVALID_LOCAL_PART - ); - $validator->setMessage( - __('"%1" uses too many characters.', $label), - \Zend_Validate_EmailAddress::LENGTH_EXCEEDED - ); - $validator->setMessage( - __("'%value%' looks like an IP address, which is not an acceptable format."), - \Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED - ); - $validator->setMessage( - __("'%value%' looks like a DNS hostname but we cannot match the TLD against known list."), - \Zend_Validate_Hostname::UNKNOWN_TLD - ); - $validator->setMessage( - __("'%value%' looks like a DNS hostname but contains a dash in an invalid position."), - \Zend_Validate_Hostname::INVALID_DASH - ); - $validator->setMessage( - __( - "'%value%' looks like a DNS hostname but we cannot match it against the hostname schema for TLD '%tld%'." - ), - \Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA - ); - $validator->setMessage( - __("'%value%' looks like a DNS hostname but cannot extract TLD part."), - \Zend_Validate_Hostname::UNDECIPHERABLE_TLD - ); - $validator->setMessage( - __("'%value%' does not look like a valid local network name."), - \Zend_Validate_Hostname::INVALID_LOCAL_NAME - ); - $validator->setMessage( - __("'%value%' looks like a local network name, which is not an acceptable format."), - \Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED - ); - $validator->setMessage( - __( - "'%value%' appears to be a DNS hostname, but the given punycode notation cannot be decoded." - ), - \Zend_Validate_Hostname::CANNOT_DECODE_PUNYCODE - ); + __('"%1" is not a valid email address.') + */ + $validator = new \Magento\Framework\Validator\EmailMinimal(); if (!$validator->isValid($value)) { - return array_unique($validator->getMessages()); + return $validator->getMessages(); } break; case 'url': diff --git a/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js b/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js index c7fb51f813ba0..bb85af3f8c8ea 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js @@ -254,6 +254,12 @@ define([ }, $.validator.messages.email ], + 'email-minimal': [ + function (value) { + return this.optional(element) || value.indexOf('@') !== -1; + }, + $.mage.__('Please enter a valid email address.') + ], 'url2': [ function (value) { return /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\u0027\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\u0027\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\u0027\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\u0027\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\u0027\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);//eslint-disable-line max-len @@ -422,7 +428,7 @@ define([ ], 'validate-email': [ function (value) { - return utils.isEmptyNoTrim(value) || /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(value);//eslint-disable-line max-len + return utils.isEmptyNoTrim(value) || value.indexOf('@') !== -1; }, $.mage.__('Please enter a valid email address (Ex: johndoe@domain.com).') ], diff --git a/app/code/Magento/User/Model/UserValidationRules.php b/app/code/Magento/User/Model/UserValidationRules.php index bfd796065d37b..d69981060c6fd 100644 --- a/app/code/Magento/User/Model/UserValidationRules.php +++ b/app/code/Magento/User/Model/UserValidationRules.php @@ -5,7 +5,7 @@ */ namespace Magento\User\Model; -use Magento\Framework\Validator\EmailAddress; +use Magento\Framework\Validator\EmailMinimal; use Magento\Framework\Validator\NotEmpty; use Magento\Framework\Validator\Regex; use Magento\Framework\Validator\StringLength; @@ -36,8 +36,8 @@ public function addUserInfoRules(\Magento\Framework\Validator\DataObject $valida $firstNameNotEmpty->setMessage(__('First Name is a required field.'), \Zend_Validate_NotEmpty::IS_EMPTY); $lastNameNotEmpty = new NotEmpty(); $lastNameNotEmpty->setMessage(__('Last Name is a required field.'), \Zend_Validate_NotEmpty::IS_EMPTY); - $emailValidity = new EmailAddress(); - $emailValidity->setMessage(__('Please enter a valid email.'), \Zend_Validate_EmailAddress::INVALID); + $emailValidity = new EmailMinimal(); + $emailValidity->setMessage(__('Please enter a valid email.'), \Magento\Framework\Validator\EmailMinimal::INVALID); /** @var $validator \Magento\Framework\Validator\DataObject */ $validator->addRule( diff --git a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php index b7562b9727a67..06320f8a12210 100644 --- a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php +++ b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php @@ -232,7 +232,7 @@ public function testValidateActionError() 'username' => 'admin2', 'firstname' => 'new firstname', 'lastname' => 'new lastname', - 'email' => 'example@domain.cim', + 'email' => 'example.domain.com', 'password' => 'password123', 'password_confirmation' => 'password123', ]; @@ -245,6 +245,6 @@ public function testValidateActionError() $body = $this->getResponse()->getBody(); $this->assertContains('{"error":1,"html_message":', $body); - $this->assertContains("'domain.cim' is not a valid hostname for email address 'example@domain.cim'", $body); + $this->assertContains('"example.domain.com" is not a valid email address.', $body); } } diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index 7682c01577b6a..dc871fa044da2 100755 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -3632,6 +3632,7 @@ ['Magento\ToolkitFramework\Helper\Cli'], ['Magento\ToolkitFramework\Config'], ['Magento\Framework\Locale\Validator', 'Magento\Framework\Validator\Locale'], + ['Magento\Framework\Validator\EmailAddress', 'Magento\Framework\Validator\Email'], ['Magento\ToolkitFramework\Fixture', 'Magento\Setup\Fixtures\Fixture'], ['Magento\ToolkitFramework\Application', 'Magento\Setup\Fixtures\FixtureModel'], ['Magento\Framework\Locale\Lists', 'Magento\Framework\Locale\TranslatedLists'], diff --git a/lib/internal/Magento/Framework/Validator/EmailAddress.php b/lib/internal/Magento/Framework/Validator/EmailAddress.php index 4ad63851412f9..3adaa3ac4786e 100644 --- a/lib/internal/Magento/Framework/Validator/EmailAddress.php +++ b/lib/internal/Magento/Framework/Validator/EmailAddress.php @@ -5,6 +5,10 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +/** + * @deprecated + * @see \Magento\Framework\Validator\EmailMinimal + */ namespace Magento\Framework\Validator; class EmailAddress extends \Zend_Validate_EmailAddress implements \Magento\Framework\Validator\ValidatorInterface diff --git a/lib/internal/Magento/Framework/Validator/EmailMinimal.php b/lib/internal/Magento/Framework/Validator/EmailMinimal.php new file mode 100644 index 0000000000000..f194dc3b7156c --- /dev/null +++ b/lib/internal/Magento/Framework/Validator/EmailMinimal.php @@ -0,0 +1,89 @@ + '"%1" is not a valid email address.' + ]; + + /** + * Validation error messages + * + * @var string[] Validation error messages + */ + private $messages = []; + + /** + * Validate email address contains '@' sign + * + * @param string $value + * + * @return bool + */ + public function isValid($value) + { + $this->messages = []; + if (!is_string($value) || strrpos($value, '@') === false) { + $translatedMessage = __($this->messageTemplates[self::INVALID], $value); + $this->messages[] = $translatedMessage; + } + + return empty($this->_messages); + } + + /** + * Return error messages (if any) after the last validation + * + * @return string[] + */ + public function getMessages() + { + return $this->messages; + } + + /** + * Sets the validation failure message template for a particular key + * + * @param string $messageString + * @param null $messageKey OPTIONAL + * + * @return $this + * @throws \InvalidArgumentException If no message template exists for key + */ + public function setMessage($messageString, $messageKey = null) + { + if ($messageKey === null) { + $keys = array_keys($this->messageTemplates); + foreach ($keys as $key) { + $this->setMessage($messageString, $key); + } + + return $this; + } + + if (!isset($this->messageTemplates[$messageKey])) { + throw new \InvalidArgumentException( + sprintf('No message template exists for key %s', $messageKey) + ); + } + + $this->messageTemplates[$messageKey] = $messageString; + + return $this; + } +} diff --git a/lib/web/mage/validation.js b/lib/web/mage/validation.js index aaece677a485d..f4f59a2ff41f5 100644 --- a/lib/web/mage/validation.js +++ b/lib/web/mage/validation.js @@ -401,8 +401,16 @@ return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value); }, - $.validator.messages.email + $.mage.__('Please enter a valid email address.') ], + + 'email-minimal': [ + function (value, element) { + return this.optional(element) || value.indexOf('@') !== -1; + }, + $.validator.messages.emailMinimal + ], + 'url2': [ function (value, element) { return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value); @@ -586,7 +594,7 @@ ], 'validate-email': [ function (v) { - return $.mage.isEmptyNoTrim(v) || /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(v); //eslint-disable-line max-len + return $.mage.isEmptyNoTrim(v) || v.indexOf('@') !== -1; }, $.mage.__('Please enter a valid email address (Ex: johndoe@domain.com).') ], diff --git a/lib/web/prototype/validation.js b/lib/web/prototype/validation.js index 616d49496e2a7..82c7bd362669e 100644 --- a/lib/web/prototype/validation.js +++ b/lib/web/prototype/validation.js @@ -560,7 +560,8 @@ Validation.addAllThese([ ['validate-email', 'Please enter a valid email address (Ex: johndoe@domain.com).', function (v) { //return Validation.get('IsEmpty').test(v) || /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(v) //return Validation.get('IsEmpty').test(v) || /^[\!\#$%\*/?|\^\{\}`~&\'\+\-=_a-z0-9][\!\#$%\*/?|\^\{\}`~&\'\+\-=_a-z0-9\.]{1,30}[\!\#$%\*/?|\^\{\}`~&\'\+\-=_a-z0-9]@([a-z0-9_-]{1,30}\.){1,5}[a-z]{2,4}$/i.test(v) - return Validation.get('IsEmpty').test(v) || /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(v) + //return Validation.get('IsEmpty').test(v) || /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(v) + return Validation.get('IsEmpty').test(v) || v.indexOf('@') !== -1 }], ['validate-emailSender', 'Please use only visible characters and spaces.', function (v) { return Validation.get('IsEmpty').test(v) || /^[\S ]+$/.test(v)