1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-25 10:33:18 +01:00

Fixing the email constraint so that it only checks strings

This commit is contained in:
Michael Dowling 2012-05-23 23:33:00 -07:00
parent d2b59d2680
commit d812cb0d39

View File

@ -12,13 +12,14 @@ class Email implements ConstraintInterface
*/
public function validate($value, array $options = null)
{
$value = (string) $value;
$valid = filter_var($value, FILTER_VALIDATE_EMAIL);
if (!$valid) {
return 'Value is not a valid email address';
if (is_string($value)) {
$value = (string) $value;
$valid = filter_var($value, FILTER_VALIDATE_EMAIL);
if ($valid) {
return true;
}
}
return true;
return 'Value is not a valid email address';
}
}