-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Labels
RFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)Validator
Description
At the moment, we have three constraints for validating date/time values:
Date
accepts\DateTime
instances and 'Y-m-d' stringsDateTime
accepts\DateTime
instances and 'Y-m-d H:i:s' stringsTime
accepts\DateTime
instances and 'H:i:s' strings
I think that's a bit confusing. Usually, a value should not be a \DateTime
or a string, but either of them; if it is a string, it should usually match a specific pattern.
Therefore I propose to deprecate all three constraints. The \DateTime
case can be solved with the Type
constraint already:
/**
* @Assert\Type('\DateTime')
*/
private $createdAt;
The second case would be covered by a new Timestamp
constraint which accepts a format as argument as supported by PHP:
/**
* @Assert\Timestamp('Y-m-d')
*/
private $createdAt;
/**
* @Assert\Timestamp('c')
*/
private $iso8601Date;
chalasr, ostrolucky and derrabus
Metadata
Metadata
Assignees
Labels
RFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)Validator