swaggest / php-json-schema

High definition PHP structures with JSON-schema based validation
MIT License
438 stars 50 forks source link

Support email addresses with Unicode charathers #159

Open ohjimijimijimi opened 3 months ago

ohjimijimijimi commented 3 months ago

Context

The email format constraint currently uses the FILTER_VALIDATE_EMAIL to validate email addresses.

Email addresses with unicode characters will not pass validation even if they are consider valid from as international email addresses.

This problem could be improved by adding FILTER_FLAG_EMAIL_UNICODE in https://github.com/swaggest/php-json-schema/blob/2b99251f31046f682b120fb807fea8ab688a493e/src/Constraint/Format.php#L55

filter_var($data, FILTER_VALIDATE_EMAIL, FILTER_FLAG_EMAIL_UNICODE) ? null : 'Invalid email';