Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Closed
wants to merge 1 commit into from
Closed

[Validator] Update DateTimeValidator to validate with format only #21905

wants to merge 1 commit into from

Conversation

lepiaf
Copy link
Contributor

@lepiaf lepiaf commented Mar 6, 2017

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

@lepiaf lepiaf changed the title [Validator] Create timestamp validator [WIP][Validator] Create timestamp validator Mar 7, 2017
@nicolas-grekas nicolas-grekas added this to the 3.x milestone Mar 7, 2017
@javiereguiluz
Copy link
Member

Thanks for this contribution!

I've read the related discussion about I'm still not convinced about the Timestamp name. It's true that technically speaking, any date + time is a "timestamp" (see https://en.wikipedia.org/wiki/Timestamp) but I'm sure that when a developers see a "TimestampValidator", they are thinking about UNIX timestamps (e.g. 1256953732).

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
Copy link
Contributor

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.

@lepiaf
Copy link
Contributor Author

lepiaf commented Mar 11, 2017

I can rework DateTime validator to be more flexible and deprecate Date and Time validators only. What do you think?

@lepiaf lepiaf changed the title [WIP][Validator] Create timestamp validator [Validator] Create timestamp validator Mar 15, 2017
@lepiaf lepiaf changed the title [Validator] Create timestamp validator [WIP][Validator] Create timestamp validator Mar 26, 2017
@lepiaf lepiaf changed the title [WIP][Validator] Create timestamp validator [WIP][Validator] Update DateTimeValidator to validate with format only Mar 26, 2017
@@ -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.
Copy link
Member

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');
Copy link
Member

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

@lepiaf lepiaf changed the title [WIP][Validator] Update DateTimeValidator to validate with format only [Validator] Update DateTimeValidator to validate with format only Apr 2, 2017
@@ -6,6 +6,8 @@ CHANGELOG

* added `AddValidatorInitializersPass`
* added `AddConstraintValidatorsPass`
* deprecate `DateValidator` in favor of `DateTimeValidator`
Copy link
Member

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`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@lepiaf
Copy link
Contributor Author

lepiaf commented Jun 21, 2017

any comment about this PR ? should I change to branch 3.4 ?

Copy link
Contributor

@ro0NL ro0NL left a 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

@lepiaf
Copy link
Contributor Author

lepiaf commented Sep 24, 2017

As I don't have time to work on this PR, I close it. Feel free to continue it :)

@lepiaf lepiaf closed this Sep 24, 2017
@lepiaf lepiaf deleted the timestamp-validator branch January 18, 2018 07:37
fabpot added a commit that referenced this pull request Sep 8, 2018
…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
hoyes added a commit to camdram/camdram that referenced this pull request May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants