Drupal email.validator service isValid accepts emails with no top-level domain (TLD)

Created on 26 October 2016, about 8 years ago
Updated 27 September 2023, about 1 year ago

Hey there,

Just ported fapi_validation over to D8. Starting to work transitioning a lot of the validation hooks to leverage core service validations instead of custom ones.

While trying to leverage \Drupal::service('email.validator')->isValid($value); I discovered that this isValid function will accept "whatever@notvalid". Without a domain this would seem to me to be an invalid email.

Steps to reproduce:

  1. Create a new custom form with a textfield for email entry.
  2. Add validation against the filed to check if the value is valid per \Drupal::service('email.validator')->isValid($value);
  3. Enter a partial email address missing the domain extension (.com, .net, .dev, etc etc)
  4. Observe how the email will be accepted.
🐛 Bug report
Status

Closed: works as designed

Version

10.0

Component
Mail 

Last updated 8 days ago

No maintainer
Created by

🇺🇸United States jnicola

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024