8000 [Validator] Fixed time constraint (support formats H, H:i and H:i:s) by bes89 · Pull Request #9163 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Closed
wants to merge 5 commits into from
Closed

[Validator] Fixed time constraint (support formats H, H:i and H:i:s) #9163

wants to merge 5 commits into from

Conversation

bes89
Copy link
Contributor
@bes89 bes89 commented Sep 28, 2013

Time constraint should support values with hours only, hours with minutes and hours 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 -

…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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be with_minutes.

Copy link
Contributor

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']) { 

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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".

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member

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

Copy link
Member

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

@fabpot
Copy link
Member
fabpot commented Jun 16, 2014

👍

@fabpot
Copy link
Member
fabpot commented Aug 31, 2014

ping @symfony/deciders

@stof
Copy link
Member
stof commented Aug 31, 2014

The support for 5:00 should be added, to avoid requiring padding the hour to 05:00, which is not user-friendly

@bes89
Copy link
Contributor Author
bes89 commented Sep 1, 2014

@fabpot @stof sorry, i reforked the symfony repo a few months ago and now i'm unable to do any change on this pull request (no write access for this PR).

I can create a new PR after merge and fix the two remaining todos.

@stof
Copy link
Member
stof commented Sep 1, 2014

hmm, this is because the PR is not created from your fork anymore as it is a new one.
We cannot merge this PR either as is because it conflicts.

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

@fabpot
Copy link
Member
fabpot commented Sep 1, 2014

Closing in favor of #11821

@fabpot fabpot closed this Sep 1, 2014
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.

7 participants
0