Skip to content

Commit ad28f5f

Browse files
committed
Enable FILTER_FLAG_EMAIL_UNICODE for email format if present (jsonrainbow#398)
1 parent af52ed9 commit ad28f5f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/JsonSchema/Constraints/FormatConstraint.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ public function check(&$element, $schema = null, JsonPointer $path = null, $i =
124124
break;
125125

126126
case 'email':
127-
if (null === filter_var($element, FILTER_VALIDATE_EMAIL, FILTER_NULL_ON_FAILURE)) {
127+
$filterFlags = FILTER_NULL_ON_FAILURE;
128+
if (defined('FILTER_FLAG_EMAIL_UNICODE')) {
129+
// Only available from PHP >= 7.1.0, so ignore it for coverage checks
130+
$filterFlags |= constant('FILTER_FLAG_EMAIL_UNICODE'); // @codeCoverageIgnore
131+
}
132+
if (null === filter_var($element, FILTER_VALIDATE_EMAIL, $filterFlags)) {
128133
$this->addError(ConstraintError::FORMAT_EMAIL(), $path, array('format' => $schema->format));
129134
}
130135
break;

0 commit comments

Comments
 (0)