Why do I receive “This value should be of type string” when using a DateTime constraint on Symfony 5?
问题 I have the following entity (only attached the relevant parts): use ApiPlatform\Core\Annotation\ApiResource; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; /** * @ApiResource(mercure=true) * @ORM\Entity(repositoryClass="App\Repository\EventRepository") */ class Event { /** * @ORM\Column(type="datetime") * @Assert\DateTime * @Assert\NotNull */ private $createdAt; public function __construct() { $this->createdAt = new \DateTime(); } public function