-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.2] [Validator] After and Before Date In Validator #3640
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
Comments
Does anyone else have any thoughts about this? @fabpot? |
Doing this is not difficult as the DateTime extension also supports the strtotime() format. One suggestion (this is something I'm using my self in an [WIP] bundle). Calling an function for getting the value will fix this, and when using the DIC, this can be as easy as calling a service inside a View. So the user can either set a static value, or a Service callback like. %service_id%:funcname Parameters for the function can be given by starting them with an underscore and then and resolving them to the parameter-name (like Controller parameters are resolved). Example.
|
A custom validator can do the trick. |
…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
I think that we should close this issue because it's been fixed by #11673. |
Enhancement: Extend the Date and DateTime validators to have options for before and after. It would be awesome if you could do
The text was updated successfully, but these errors were encountered: