-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Make email validation only validate @ sign presence, fixes #4547 #9087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c736224
Make email validation only validate @ sign presence, fixes #4547
sambolek 6ba09d6
Merge remote-tracking branch 'upstream/develop' into issue-4547
sambolek dc8867d
Remove dependency on Zend validator, make validator logic more simila…
sambolek 4a3612f
Add obsolete EmailAddress validator class
sambolek 196994d
Attempt to create Email validator by implementing AbstractValidator i…
sambolek c6fbf5c
Fix exception, use Phrase instead of plain string
sambolek 5d7d971
Fix logical error
sambolek 2775007
Fix logical error
sambolek a476b05
Unify messages
sambolek c8239e0
Fix integration test failure, we no longer check for valid hostname i…
sambolek 9263b0e
Fix failing static tests
sambolek 9d9be7d
Fix phpcs & phpmd warnings
sambolek 2ef2dfd
Merge remote-tracking branch 'upstream/develop' into issue-4547
sambolek 764f757
Revert emailSender js validator change
sambolek 6e3f8e7
Merge remote-tracking branch 'upstream/develop' into issue-4547
sambolek 0095a1b
Implement EmailMinimal validator, replace usages of old Email validator
sambolek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/** | ||
* Email address validator | ||
* | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Framework\Validator; | ||
|
||
class EmailMinimal implements \Zend_Validate_Interface | ||
{ | ||
const INVALID = 'emailAddressInvalid'; | ||
|
||
/** | ||
* Validation failure message template definitions | ||
* | ||
* @var string[] | ||
*/ | ||
private $messageTemplates = [ | ||
self::INVALID => '"%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; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to keep inheritance from Zend Framework 1 class. Please mark this class as
@deprecated
without changes and create a new one with proper logic.As we don't have
EmailAnything
exceptEmailAddress
, I believe simplyEmail
would be a good name for such class.