10000 [Validator] new email validation option to match with w3c official specification by guillemfondin · Pull Request #47872 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] new email validation option to match with w3c official specification #47872

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.

Sign up for GitHub

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

Merged

Conversation

guillemfondin
Copy link
Contributor
@guillemfondin guillemfondin commented Oct 15, 2022
Q A
Branch? 6.2
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #47712
License MIT
Doc PR symfony/symfony-docs#17360

WHAT

Email validator no matches with w3c official specication (that allow no tld) see #47712 for details.

WHY

In general, for public common usage, developers may not need to give users this liberty.
Except for specific use case, (internal email for eg) in companies...

HOW

Add an option for accept tld (already exist Email::VALIDATION_MODE_HTML5) or not (official spec Email::VALIDATION_MODE_HTML5_ALLOW_NO_TLD)

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbot carsonbot changed the title WIP: [Validator] Add new email validation option to match with w3c official specification [Validator] WIP: Add new email validation option to match with w3c official specification Oct 15, 2022
@guillemfondin guillemfondin force-pushed the feature/new-standard-email-validation branch from b62971f to 7cb0c02 Compare October 15, 2022 13:31
@maxbeckers
Copy link
Contributor

@guillemfondin could you please add some unit tests for the change.

@guillemfondin
Copy link
Contributor Author

@maxbeckers Of course :)

@nicolas-grekas nicolas-grekas changed the title [Validator] WIP: Add new email validation option to match with w3c official specification [Validator] new email validation option to match with w3c official specification Oct 17, 2022
Copy link
Member
@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

This approach makes sense to me. Accepting emails with no TLD by default would likely make more bad than good in practice. We'd better allow this in an opt-in way. The alternative could be to just do nothing BTW. The motivation for changes in Symfony should be based on real-world use cases.

@Sajito
Copy link
Sajito commented Oct 17, 2022

Weird having discussion in two seperate places, thanks @guillemfondin for notifying me :)

Personally I feel a bit uncomfortable with this change. Not because I need the ability to allow emails without a tld, actually I don't have an use-case for this feature. I have filed the issue only because during some tests I got to the point, where the browser validator said the email is fine, while the backend validator said it's invalid and that made me curious.

Having a validator, which claims it does the same check as the browser and is also named to represent this, but actually having a difference is weird. It get's even more weird, when the html5 mode (named after the html5 validator), does something different than the actual html5 validator and the "real" html5 validator has a name not even related to html5.

I'd say the naming should move to something like "html5" and "html5-force-tld". The only issue is the BC implication.
But changing this really feels hacky and I can understand, if that's not the way to go. I've pushed my proposal into my fork, just to make them visible. Commit is here.
Alternatively this new mode should make clear it's actually html5. Maybe strict-html5 or something like that.

Copy link
Member
@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

I think this approach makes sense.

@fabpot fabpot force-pushed the feature/new-standard-email-validation branch from d0da11d to 23047d9 Compare October 20, 2022 06:44
@fabpot
Copy link
Member
fabpot commented Oct 20, 2022

Thank you @guillemfondin.

@fabpot fabpot merged commit 43a56e8 into symfony:6.2 Oct 20, 2022
wouterj added a commit to symfony/symfony-docs that referenced this pull request Oct 23, 2022
…ndin)

This PR was squashed before being merged into the 6.2 branch.

Discussion
----------

[Validator] Email -  new `allow-no-tld` mode

See [Related feature PR](symfony/symfony#47872)

As suggested [here](symfony/symfony#47712 (comment)) ; the actual description of `html5` mode isn't consistent with the one provided by browsers. Browsers allow no tld, `html5` mode not.

I proprose to move the actual description of `html5` mode to the new `allow-no-tld` mode description, and clarify the subtlety (force .tld) of the actual `html5` mode.

Commits
-------

485d57e [Validator] Email -  new `allow-no-tld` mode
@fabpot fabpot mentioned this pull request Oct 24, 2022
fabpot added a commit that referenced this pull request May 7, 2025
…ion modes can be configured (xabbuh)

This PR was merged into the 6.4 branch.

Discussion
----------

[FrameworkBundle] ensure that all supported e-mail validation modes can be configured

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #60352
| License       | MIT

this update was forgotten when adding the `html5-allow-no-tld` e-mail validation mode in #47872

Commits
-------

b8b3c37 ensure that all supported e-mail validation modes can be configured
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.

[Validator] EmailValidator in html5 mode does not match actual html validator
9 participants
0