I tried to add validation to dateTime with symfony Assert and API platform :
use Symfony\Component\Validator\Constraints as Assert;
denormalizationContext={"disable_type_enforcement"=true}
/**
* @ORM\Column(type="datetime")
* @Groups({"invoices_read", "customers_read", "invoices_subresource"})
* @Assert\NotBlank(message="La date de la facture doit être renseignée !")
* @Assert\DateTime(message="La date doit être au format YYYY-MM-DD")
*/
private $sentAt;
I tried to post data with postman . I always receive :
{
"@context": "/api/contexts/ConstraintViolationList",
"@type": "ConstraintViolationList",
"hydra:title": "An error occurred",
"hydra:description": "sentAt: This value should be of type string.",
"violations": [
{
"propertyPath": "sentAt",
"message": "This value should be of type string."
}
]
}