-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Added a format option to the DateTime constraint. #14531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
format
option to the DateTime
constraint.
Some feedback? |
Thank you for the PR @dosten! As I said in the ticket, I don't want to deprecate Date and Time. Apart from that, this PR looks good. |
The UPGRADE-2.8.md need to be removed too? |
@webmozart done, if a want to add a violation to a validator is this considered a BC break? Ex: |
ping @webmozart |
ping @webmozart |
Any feedback on this? |
Looks good to me. But doesn't it make sense to also have the same option in the |
@xabbuh My first idea was to deprecate the Date and Time constraints because we can do the same with this constraint now. If i add this to the Date (or Time) constraint IMO we would have two constraints that can do the same. use Symfony\Component\Validator\Constraints\Date;
use Symfony\Component\Validator\Constraints\DateTime;
use Symfony\Component\Validator\Constraints\Time;
// This constraints are equivalent.
$constraint = new DateTime(['format' => 'Y-m-d']);
$constraint = new Date();
// This constraints are equivalent.
$constraint = new DateTime(['format' => 'H:i:s']);
$constraint = new Time(); |
@dosten What you describe will actually be the case right now with only having the Edit: I mean, we could now indeed use the |
I agree with @xabbuh on the deprecation of |
I agree with you, IMO we should deprecate these constraints. |
Can you check this @webmozart ? We can merge this one and discuss the deprecation of the other constraints in another issue? |
ping someone |
Closed in favor of #17553 |
This PR adds a new
format
option to theDateTime
constraint and deprecate theDate
andTime
constraints in favor of this new option.