I need to restrict the usage of German umlauts (äÄöÖüÜ) in email addresses.
So I quickly created a custom validation rule in my AppServiceProvider:
Validator::extend('without_umlauts', function ($attribute, $value) {
return preg_match('/^[^äÄöÖüÜ]*$/u', $value);
});
The regex (see visualization) seems to work pretty much as expected and detects the given umlauts in basic strings.
The validation rule above works with input fields type="text" and the following input values:
tä[email protected]
jane-doe@täst.com
However, the rule does not work in Google Chrome as soon as I use type="email".
I assume the reason for this is that behind the scenes Laravel Google Chrome casts the domain part of the email address to IDNA ASCII:
[email protected]
I already tried to use idn_to_utf8() on the $value but it didn't work.
How can I restrict the usage of umlauts (special characters) in the domain name of the email address? Umlauts should not be allowed in the whole email address string.
Update: It works perfectly well in Firefox. It seems to be a browser-related issue (instead of Regex/Laravel).