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:
parent
d2b59d2680
commit
d812cb0d39
@ -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';
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user