-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Fixed time constraint (support formats H, H:i and H:i:s) #9163
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
…y, with minutes and with minutes and seconds | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | -
…ith minutes and with minutes and seconds | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | -
{ | ||
parent::__construct($options); | ||
|
||
if (isset($options['withMinutes']) && !isset($options['withSeconds']) && $options['withMinutes'] == false) { |
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 with_minutes
.
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.
if (isset($options['with_minutes']) && !isset($options['with_minutes']) && !$options['with_minutes']) {
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.
@stloyd Correct! But if we do so then we must also rename the properties e.g. protected $with_minutes;
and that's not want we want to do.
We need something that converts option names to camelcased strings. How is this handled in other components?
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.
In overall php variables are camelCased, while array keys are written with underscore.
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.
take a look into the base constraint class how options are set:
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraint.php#L98
if you pass an option named "with_minutes" it's value is not set for the property "withMinutes".
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.
In https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraints/Length.php
The options are first passed to the parents constructor, and then the properties are checked.
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.
Camel casing is fine here.
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 should be === false
rather than == false
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.
my own comment is not fixed though
👍 |
ping @symfony/deciders |
The support for |
hmm, this is because the PR is not created from your fork anymore as it is a new one. However, there is a way to create a local branch based on the branch you use for this PR, allowing you to work on it again and to create a new PR with it: git fetch https://github.com/symfony/symfony.git refs/pull/9163
git branch time_constraint_format FETCH_HEAD
git checkout time_constraint_format |
Closing in favor of #11821 |
Time constraint should support values with hours only, hours with minutes and hours with minutes and seconds