-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Update DateTimeValidator to validate with format only #21905
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
lepiaf
commented
Mar 6, 2017
•
edited
Loading
edited
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | no |
BC breaks? | no |
Deprecations? | yes |
Tests pass? | yes |
Fixed tickets | #11925 |
License | MIT |
Doc PR | symfony/symfony-docs#7583 |
- update datetime validator
- update documentation for datetime validator
- add deprecation on DateValidator, TimeValidator
- update UPGRADE file
Thanks for this contribution! I've read the related discussion about I'm still not convinced about the Don't you think that "DateTime" is a better name? A "DateTime" can be a "date", a "time", a "date + time", a "UNIX timestamp", etc. |
@@ -1,6 +1,13 @@ | |||
CHANGELOG | |||
========= | |||
|
|||
3.4.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still 3.3 :), same for all deprecation notices.
I can rework DateTime validator to be more flexible and deprecate Date and Time validators only. What do you think? |
@@ -18,6 +18,8 @@ | |||
* @Target({"PROPERTY", "METHOD", "ANNOTATION"}) | |||
* | |||
* @author Bernhard Schussek <[email protected]> | |||
* | |||
* @deprecated Since version 3.3, to be removed in 4.0. Use Symfony\Component\Validator\Constraints\DateTimeValidator instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you also need to add the E_USER_DEPRECATED on top of the file
*/ | ||
public function getRequiredOptions() | ||
{ | ||
return array('format'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
making it required is a BC break. It should keep the existing default
@@ -6,6 +6,8 @@ CHANGELOG | |||
|
|||
* added `AddValidatorInitializersPass` | |||
* added `AddConstraintValidatorsPass` | |||
* deprecate `DateValidator` in favor of `DateTimeValidator` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deprecated
@@ -6,6 +6,8 @@ CHANGELOG | |||
|
|||
* added `AddValidatorInitializersPass` | |||
* added `AddConstraintValidatorsPass` | |||
* deprecate `DateValidator` in favor of `DateTimeValidator` | |||
* deprecate `TimeValidator` in favor of `DateTimeValidator` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
any comment about this PR ? should I change to branch 3.4 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be 3.4 yes :)
What aboutd deprecating \DateTime
instances as well? It's weird to use a datetime validator for an already valid datetime object.
Perhaps add constants for pre-defined formats, that be nice :) i.e. FORMAT_DATE/TIME/TIME_WITHOUT_SECONDS
As I don't have time to work on this PR, I close it. Feel free to continue it :) |
…Date|Time|DateTime constraints (ro0NL) This PR was merged into the 4.2-dev branch. Discussion ---------- [Validator] Deprecate validating DateTimeInterface in Date|Time|DateTime constraints | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #11925 | License | MIT | Doc PR | symfony/symfony-docs#7583 (old PR but not really needed now) Easy version of #21905. I think individual naming has value. Also the goal is to move forward to use `Type` really, not to bother with constraint renames. Commits ------- 5454e6f [Validator] Deprecate validating DateTimeInterface in Date|Time|DateTime constraints
Date and Time validators only accept strings since symfony/symfony#21905