-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
[WCM] Added information about the new date handling in the comparison constraints and Range #4143
Conversation
webmozart
commented
Aug 18, 2014
Q | A |
---|---|
Doc fix? | no |
New docs? | yes (symfony/symfony#11673) |
Applies to | 2.6+ |
Fixed tickets | - |
<property name="deliveryDate"> | ||
<constraint name="GreaterThan">today</constraint> | ||
</property> | ||
</class> |
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.
I prefer to have fully working XML examples:
<!-- src/Acme/OrderBundle/Resources/config/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
<class name="Acme\OrderBundle\Entity\Order">
<property name="deliveryDate">
<constraint name="GreaterThan">today</constraint>
</property>
</class>
</constraint-mapping>
This also applies to the other XML code blocks below.
…ts and Range (webmozart) This PR was merged into the 2.6-dev branch. Discussion ---------- [Validator] Added date support to comparison constraints and Range | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #3640, #7766, #9164, #9390, #8300 | License | MIT | Doc PR | symfony/symfony-docs#4143 This commit adds frequently requested functionality to compare dates. Since the `DateTime` constructor is very flexible, you can do many fancy things now such as: ```php /** * Only accept requests that start in at least an hour. * @Assert\GreaterThanOrEqual("+1 hours") */ private $date; /** * Same as before. * @Assert\Range(min = "+1 hours") */ private $date; /** * Only accept dates in the current year. * @Assert\Range(min = "first day of January", max = "first day of January next year") */ private $date; /** * Timezones are supported. * @Assert\Range(min = "first day of January UTC", max = "first day of January next year UTC") */ private $date; ``` Commits ------- 60a5863 [Validator] Added date support to comparison constraints and Range
…ts and Range (webmozart) This PR was merged into the 2.6-dev branch. Discussion ---------- [Validator] Added date support to comparison constraints and Range | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #3640, #7766, #9164, #9390, #8300 | License | MIT | Doc PR | symfony/symfony-docs#4143 This commit adds frequently requested functionality to compare dates. Since the `DateTime` constructor is very flexible, you can do many fancy things now such as: ```php /** * Only accept requests that start in at least an hour. * @Assert\GreaterThanOrEqual("+1 hours") */ private $date; /** * Same as before. * @Assert\Range(min = "+1 hours") */ private $date; /** * Only accept dates in the current year. * @Assert\Range(min = "first day of January", max = "first day of January next year") */ private $date; /** * Timezones are supported. * @Assert\Range(min = "first day of January UTC", max = "first day of January next year UTC") */ private $date; ``` Commits ------- 60a5863 [Validator] Added date support to comparison constraints and Range
} | ||
|
||
Be aware that PHP will use the server's configured timezone to interpret these | ||
dates. If you want to fix the timezone, append it to the date string: |
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.
I have a minor question regarding this phrase:
If you want to fix the timezone ...
Does fix
always imply that something is broken? In that case, we could change it for something like this:
If you want to use a custom timezone ...
If you want to set a different timezone ...
If you want to configure the timezone explicitly ...
What I mean is that the server timezone isn't broken, it's just different from what we may need.
@webmozart could you please update this PR to fix the comments? |
@@ -8,7 +8,7 @@ Validates that a value is equal to another value, defined in the options. To | |||
force that a value is *not* equal, see :doc:`/reference/constraints/NotEqualTo`. | |||
|
|||
.. caution:: | |||
|
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.
Isn't it useful to explain how to compare Date
instances here too?
@webmozart Will you be able to complete this or will you prefer if somebody takes this over? |
…ts and Range (webmozart) This PR was merged into the 2.6-dev branch. Discussion ---------- [Validator] Added date support to comparison constraints and Range | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #3640, #7766, #9164, #9390, #8300 | License | MIT | Doc PR | symfony/symfony-docs#4143 This commit adds frequently requested functionality to compare dates. Since the `DateTime` constructor is very flexible, you can do many fancy things now such as: ```php /** * Only accept requests that start in at least an hour. * @Assert\GreaterThanOrEqual("+1 hours") */ private $date; /** * Same as before. * @Assert\Range(min = "+1 hours") */ private $date; /** * Only accept dates in the current year. * @Assert\Range(min = "first day of January", max = "first day of January next year") */ private $date; /** * Timezones are supported. * @Assert\Range(min = "first day of January UTC", max = "first day of January next year UTC") */ private $date; ``` Commits ------- 60a5863 [Validator] Added date support to comparison constraints and Range
Hi @webmozart. Do you have some time soon to finish this PR? If you don't, please say so as we can then assign it to someone else during the doc sprint day on May 23rd. Thanks! |
This PR has been finished in #5384 |
closing in favor of #5384 |
…mparison constraints and Range (webmozart, javiereguiluz) This PR was submitted for the 2.7 branch but it was merged into the 2.6 branch instead (closes #5384). Discussion ---------- Added information about the new date handling in the comparison constraints and Range | Q | A | ------------- | --- | Doc fix? | no | New docs? | yes (symfony/symfony#11673) | Applies to | 2.6+ | Fixed tickets | - This PR finishes #4143 Commits ------- b6c1a93 Added the "payload" option back 7ef2e6a Show annotations first e3efbbf Reordered the code blocks to show Annotations, YAML, XML and PHP 39f46e1 Fixed the issues reported by @xabbuh 7003445 Finished the documentation of the new data comparison validators 1fa69fe Added information about the new date handling in the comparison constraints and Range