소스 검색

[Validator] Date: check if the value is a DateTime instance

Francis Besset 14 년 전
부모
커밋
c6d39ed61f
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      src/Symfony/Component/Validator/Constraints/DateValidator.php

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

@@ -25,6 +25,10 @@ class DateValidator 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');
         }