This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests
Fabien Potencier a7c1ff8558 merged branch ajessu/time_validator (PR #1254)
# Commits

ca52a04 [Validator] Allow DateTime objects as valid Times

# Discussion

## [Validator] Allow DateTime objects as valid Times

Also added tests for `DateTime` objects as valid on `Date` and `Time` constraints.

I didn't include the test for the `DateTime` constraint, as it's already included in this PR:

https://github.com/symfony/symfony/pull/1085

---------------------------------------------------------------------------

## fabpot @ 2011/06/09 09:07:21 -0700

I don't think it makes sense to use a \DateTime instance to represent a Time.

---------------------------------------------------------------------------

## ajessu @ 2011/06/09 09:33:20 -0700

If I have an entity with a doctrine type `Time`:

    Time (DateTime instance where only H:i:s get persisted)

```php
<?php
    /**
     * @ORM\Column(type="time")
     * @Assert\Time()
     */
    protected $startTime;
```

and I create a form out of this Entity, a `DateTime` object is passed when the form is submitted.

This generates an `UnexpectedTypeException`.

I just made this change to match the `Date` validator with the doctrine type `Date`, which also shares this behavior:
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraints/DateValidator.php#L28

    Date (DateTime instance where only Y-m-d get persisted)
2011-06-14 12:08:41 +02:00
..
Symfony/Tests merged branch ajessu/time_validator (PR #1254) 2011-06-14 12:08:41 +02:00
bootstrap.php replaced symfony-project.org by symfony.com 2011-03-06 12:40:06 +01:00