Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Extend email validation according to RFC 5322 #1969

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
wants to merge 5 commits into from
Closed

Extend email validation according to RFC 5322 #1969

wants to merge 5 commits into from

Conversation

ntzrbtr
Copy link

@ntzrbtr ntzrbtr commented Aug 16, 2011

Make it possible to validate a list of email addresses as specified in RFC 5322, section 3.4 (i.e. have multiple email addresses separated by comma).

@stloyd
Copy link
Contributor

stloyd commented Aug 16, 2011

You need to fix CS. Also you should allow to specify separator (not hardcode ,). There is missing trim() call after explode (ie. [email protected], [email protected], [email protected]) and IMO there should be two different msgs for error (one for multiple and one for single).

if ('' === $part) {
$valid = false;
}
else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The else should be on the same line than the closing curly brace (same for next places)

@ntzrbtr
Copy link
Author

ntzrbtr commented Aug 16, 2011

I fixed the code to adhere to the coding convention, implemented the suggested trimming of the split values and added a separate error message for the case that the multiple option is set.
Regarding the separator, I wanted to be as close as possible to the RFC and it only allows a comma as a separator.

@stloyd
Copy link
Contributor

stloyd commented Aug 16, 2011

I'm not convinced to be strict to RFC because I'm still rewriting EmailValidator (see #1581) and I saw many strange valid email addresses already ;-) But of course if you think its good enough and @fabpot agree I give +1 until for merge (if I dont end refactoring and making my PR for EmailValidator).

@ntzrbtr
Copy link
Author

ntzrbtr commented Aug 17, 2011

@stloyd I thought about your comment once more and you got me convinced, so I made the separator configurable in the constraint as well (with the standard comma being the default).

@fabpot
Copy link
Member

fabpot commented Sep 28, 2011

The email validator is just for the addr-spec part of the specification (3.4.1), not about validating the address. As specified in section 3.4, the address is in fact richer than just what is implemented here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants