-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Support \DateInterval in comparison constraints #33401
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
9f86290
to
2554641
Compare
… (fancyweb) This PR was squashed before being merged into the 3.4 branch (closes #33434). Discussion ---------- [Validator] Add ConstraintValidator::formatValue() tests | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - So #33401 tests can be built on top of this. Commits ------- b688aa3 [Validator] Add ConstraintValidator::formatValue() tests
… (fancyweb) This PR was squashed before being merged into the 3.4 branch (closes #33434). Discussion ---------- [Validator] Add ConstraintValidator::formatValue() tests | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - So symfony/symfony#33401 tests can be built on top of this. Commits ------- b688aa31ec [Validator] Add ConstraintValidator::formatValue() tests
af34089
to
9a19842
Compare
9a19842
to
1b0654a
Compare
1b0654a
to
0c7342d
Compare
src/Symfony/Component/Validator/Util/DateIntervalComparisonHelper.php
Outdated
Show resolved
Hide resolved
0c7342d
to
1664890
Compare
I find the PR description a bit confusing. Is the goal of this PR to support specifying intervals as an input of the constraints or do you really want to be able to have your properties being intervals? From reading I understand the latter, but I don't really see a use case for that. |
The latter. A class property holds a |
'h' => 'hour', | ||
'i' => 'minute', | ||
's' => 'second', | ||
'f' => 'microsecond', |
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.
this formatting logic is English-only, which looks bad.
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.
As we did for dates just above, the format is hardcoded here except in this case there are words.
1664890
to
3c5df46
Compare
I just rebased this one on master. |
I must admit there is a problem on this one with the hardcoded English formatting that does not follow any standard (contrary to the hardcoded RFC-3339 date format). How could we deal with this? |
3c5df46
to
f4b9bf6
Compare
This feature would be very interesting :) |
@fabpot I am closing this one as it cannot be merged with a fixed format. I am still working on the format customisation sometimes but it is not ready yet. I will reopen a new PR once everything is ready. |
That feature allows to use the
Range
and all comparisons constraints on\DateInterval
values.TODO :
ConstraintValidator::formatValue()
withPRETTY_DATE_INTERVAL
ComparisonValidatorDateIntervalHelper
DivisibleBy
- this constraint is a comparison and there is no test with dates, so I guess a proper exception needs to be thrown. - see [Validator] Only handle numeric values in DivisibleBy #33435Edit : waiting for other related PRs to be treated before resynchronizing everything on this one.