[Validator] Allow DateTime objects as valid DateTimes

This commit is contained in:
Jordi Boggiano 2010-09-21 22:20:26 +02:00 committed by Fabien Potencier
parent 2862c6cce4
commit 82f6a68eb2

View File

@ -16,6 +16,10 @@ class DateTimeValidator extends ConstraintValidator
return true;
}
if ($value instanceof \DateTime) {
return true;
}
if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString()'))) {
throw new UnexpectedTypeException($value, 'string');
}