Forráskód Böngészése

[Validator] Allow DateTime objects as valid DateTimes

Jordi Boggiano 14 éve
szülő
commit
82f6a68eb2

+ 4 - 0
src/Symfony/Component/Validator/Constraints/DateTimeValidator.php

@@ -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');
         }