webmozarts / assert

Assertions to validate method input/output with nice error messages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unicode flag in email validation

gaelreyrol opened this issue · comments

Hi,

I noticed that the assertion made by Assertion::email() does not allow Unicode characters. Since 2012, Unicode characters above U+007F encoded as UTF-8 are allowed in the local part.

PHP 7.1 added the flag FILTER_FLAG_EMAIL_UNICODE that can be used with FILTER_VALIDATE_EMAIL to accept those Unicode characters.

filter_var($value, FILTER_VALIDATE_EMAIL, FILTER_FLAG_EMAIL_UNICODE)

A simple test with two emails allows to check the difference:

  • foo@bar.com
  • föö@bar.com

I can submit a PR to add the flag with an extra argument but maybe you would prefer to add a new method so I prefer to discuss it here before.

Regards